This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/20019] incorrect overflow warning


------- Additional Comments From igodard at pacbell dot net  2005-02-17 04:10 -------
Please: 

yes, the int value lwbi arising from the conversion of char(0x80) is the int 
value 0xffffff80, i.e. int(-128); you are quite right about that. That value is 
being *subtracted* from the int value upbi arising from the conversion of 
char(0x7f) which is the value 0x0000007f, i.e. 127. If you subtract -128 from 
127, i.e (127 - (-128)), the result is 255, a positive number and there is NO 
overflow. This is signed subtract and it is permitted to subtract a negative 
from a positive. The result is exact.

The result of the subtract is the positive number int(255). That can be 
converted to size_t (which is unsigned in in this case) also without overflow.

Yet there is still a warning message.

If the problem here is not clear, please pass this report on to your other 
colleagues for a second opinion. Thank you.

Ivan

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20019


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]