public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long @ 2010-10-04 17:58 anders_jagd at yahoo dot com 2010-10-04 18:01 ` [Bug c/45884] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: anders_jagd at yahoo dot com @ 2010-10-04 17:58 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45884 Summary: Incorrect removal of check for "less than zero" after adding value to (signed) long Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: anders_jagd@yahoo.com Created attachment 21959 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=21959 Source (test.c), Makefile, Binaries, test.i, gcc -dumpspecs etc. See README.txt When compiled with -O2, the below (val < 0) check is, under some conditions (see attachment), optimized away: ... long val10, val; char *s; ... if((*s >= '0') && (*s <= '9')) { val10 = val * 10; // Skip overflow check, not the issue we are showing val = val10 + (*s - '0'); /****** OPTIMIZED AWAY IN CASE OF -O2 ******/ if(val < 0) { /* Overflow */ return -1; } ... } Build on ubuntu (2.6.32-25-generic) gcc version 4.4.3-4ubuntu5 machine i486-linux-gnu Attaching complete test case with: Makefile Source (test.c) Binaries Result from compiling with -save-temps (test.i) System configuration, gcc -dumpspecs, etc. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/45884] Incorrect removal of check for "less than zero" after adding value to (signed) long 2010-10-04 17:58 [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long anders_jagd at yahoo dot com @ 2010-10-04 18:01 ` pinskia at gcc dot gnu.org 2010-10-04 18:12 ` anders_jagd at yahoo dot com 2010-10-04 18:13 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2010-10-04 18:01 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45884 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-04 18:01:46 UTC --- Signed integer overflow is undefined so what GCC is doing is correct. Use -fwarpv if you want it to be defined to wrapping. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/45884] Incorrect removal of check for "less than zero" after adding value to (signed) long 2010-10-04 17:58 [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long anders_jagd at yahoo dot com 2010-10-04 18:01 ` [Bug c/45884] " pinskia at gcc dot gnu.org @ 2010-10-04 18:12 ` anders_jagd at yahoo dot com 2010-10-04 18:13 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: anders_jagd at yahoo dot com @ 2010-10-04 18:12 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45884 --- Comment #2 from Anders Jagd <anders_jagd at yahoo dot com> 2010-10-04 18:12:16 UTC --- (In reply to comment #1) > Signed integer overflow is undefined so what GCC is doing is correct. Use > -fwarpv if you want it to be defined to wrapping. I acknowledge that ISO/IEC 9899 defines integer overflow to be undefined. What GCC doing is thus "not incorrect". However, would this maybe be a bit too aggressive optimization at -O2 ? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/45884] Incorrect removal of check for "less than zero" after adding value to (signed) long 2010-10-04 17:58 [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long anders_jagd at yahoo dot com 2010-10-04 18:01 ` [Bug c/45884] " pinskia at gcc dot gnu.org 2010-10-04 18:12 ` anders_jagd at yahoo dot com @ 2010-10-04 18:13 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2010-10-04 18:13 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45884 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-04 18:13:15 UTC --- See -fstrict-overflow too. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-04 18:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-10-04 17:58 [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long anders_jagd at yahoo dot com 2010-10-04 18:01 ` [Bug c/45884] " pinskia at gcc dot gnu.org 2010-10-04 18:12 ` anders_jagd at yahoo dot com 2010-10-04 18:13 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).