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: "agner at agner dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Jul 2011 07:44:45 +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 #10 from Agner Fog <agner at agner dot org> 2011-07-25 07:43:58 UTC ---
I still think that a compiler should be predictable and consistent. It is
inconsistent that a+5<a = false produces a warning, while abs(a)<0 = false
does not. Both expressions could be intended overflow checks.
Besides, some compilers produce a warning when a branch condition is always
true or always false. That is sound behavior because it is likely to be a bug.
gcc does not produce a warning when optimizing away something like if (2+2 !=
4)