This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20019] incorrect overflow warning
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Feb 2005 04:10:15 -0000
- Subject: [Bug c++/20019] incorrect overflow warning
- References: <20050217025913.20019.igodard@pacbell.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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