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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> 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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
> 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.
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.