public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eggert at gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/48267] New: incorrect signed overflow warning when a pointer cannot possibly overflow Date: Thu, 24 Mar 2011 08:53:00 -0000 [thread overview] Message-ID: <bug-48267-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48267 Summary: incorrect signed overflow warning when a pointer cannot possibly overflow Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: eggert@gnu.org I ran into this problem when compiling the GNU Emacs trunk with a GCC 4.5.2 that I built on RHEL 5.5 (x86-64). I narrowed it down to the following stripped-down test case. This smells different from the previous bug report I filed in this area (PR48228) on the same platform. When I compile the following program with "gcc -S -Wstrict-overflow -O2" GCC reports "warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2". This warning is incorrect, since signed overflow is obviously impossible in this function: the only pointers computed are head_table and head_table + 1, which are both in range. Changing the "+ 1" to "+ 7" generates even more warnings, though the program is still correct. int head_table[7]; int foo (void) { const int *p; int x = 0; for (p = head_table; p < head_table + 1; p++) x ^= *p; return x; }
next reply other threads:[~2011-03-24 7:58 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-03-24 8:53 eggert at gnu dot org [this message] 2011-03-24 12:18 ` [Bug middle-end/48267] " rguenth at gcc dot gnu.org 2021-09-28 9:09 ` 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-48267-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).