#543 bogus(?) warning

open
nobody
None
1
2011-07-23
2011-07-23
No

mov eax, ~(1<<31)

Still producing "dword data exceeds bounds.

Discussion

  • H. Peter Anvin

    H. Peter Anvin - 2011-07-23

    The right hand expression has the value of 0xFFFF_FFFF_7FFF_FFFF which is correctly not either sign- or zero-extendable from the 32-bit truncated value. The issue here is the handling of - or ~ in these kinds of expressions: they end up extending an expression theoretically "to infinity", even though that is presumably not the intention of the programmer.

     
  • nasm64developer

    nasm64developer - 2011-07-23

    > even though that is presumably not the
    > intention of the programmer.

    The programmer's intent is not clear from
    the code. Yes, EAX suggests 32 bits... but
    no, it's not sufficient to suggest that there
    should be no bounds warnings.

    The programmer should explicitly specify
    mov eax, 0xFFFFFFFF & (~(1<<31)) so that
    the 32-bit intent becomes non-ambiguous
    and the warning goes away.

     
  • Nobody/Anonymous

    I don't think typing eax, 0xFFFFFFFF & (~(1<<31)) is a good idea. In real we should check the size of destination, if it fits the source -- then no warning here.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks