public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anders_jagd at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45884] New: Incorrect removal of check for "less than zero" after adding value to (signed) long Date: Mon, 04 Oct 2010 17:58:00 -0000 [thread overview] Message-ID: <bug-45884-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2010-10-04 17:58 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-10-04 17:58 anders_jagd at yahoo dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-45884-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).