• AVR Freaks

Hot!XC8 V2.10 warning

Author
allan.
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2016/03/07 22:47:37
  • Location: 0
  • Status: offline
2019/09/17 17:41:58 (permalink)
0

XC8 V2.10 warning

With the following 2 defines in my code:
#define ZZZ 0xf863
#define ZZZ_LOW (ZZZ & 0x00FF)
 
The compiler issues a warning at this statement:
TMR0L = ZZZ_LOW;
warning: (751) arithmetic overflow in constant expression
 
This was not a warning for XC8 V1.45 and earlier.
The code functions in practice but how can I fix this?
 
Thanks
 
#1

4 Replies Related Threads

    mbrowning
    USNA79
    • Total Posts : 1537
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: XC8 V2.10 warning 2019/09/17 19:26:04 (permalink)
    +1 (1)
    Maybe change ZZZ to this
    #define ZZZ 0xf863u 

    Go Navy! Beat Army!
    #2
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11347
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 V2.10 warning 2019/09/17 19:36:58 (permalink)
    0
    #define ZZZ 0xf863u

     
    I wouldn't expect that to have any effect since 0xf863 should already be unsigned.
    #3
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 V2.10 warning 2019/09/17 19:52:55 (permalink)
    +2 (2)
    It's XC8 being paranoid about integer promotions.
    It doesn't matter what casting you try to add to suppress the warning, it survives them all!
    This has been around (in one form or another) for years.
    e.g. https://www.microchip.com/forums/m736903.aspx from 2013 and v1.20
    https://www.microchip.com/forums/m955127.aspx from 2016 and v1.38
    post edited by ric - 2019/09/17 19:57:51

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    allan.
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2016/03/07 22:47:37
    • Location: 0
    • Status: offline
    Re: XC8 V2.10 warning 2019/09/19 04:19:10 (permalink)
    +1 (1)
    JTemples was correct and after reviewing Ric's 2 links, I will put up with the warning.
    Thanks for the replies.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5