This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49820] Explicit check for integer negative after abs optimized away
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 24 Jul 2011 09:41:00 +0000
- Subject: [Bug c/49820] Explicit check for integer negative after abs optimized away
- Auto-submitted: auto-generated
- References: <bug-49820-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49820
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-07-24 09:40:57 UTC ---
(In reply to comment #8)
> Why is the behavior different for signed and unsigned?
> The expression (a + 5 < a) is reduced to always false when a is signed, but not
> when a is unsigned.
Because for unsigned, wrapping is the behavior for UINT_MAX +1. As there is no
overflow for unsigned integer, a+5 can be less than a.