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 preprocessor/55715] New: bogus overflow warning for #if A-B when A<0 & B==minimum integer Date: Mon, 17 Dec 2012 07:23:00 -0000 [thread overview] Message-ID: <bug-55715-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55715 Bug #: 55715 Summary: bogus overflow warning for #if A-B when A<0 & B==minimum integer Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor AssignedTo: unassigned@gcc.gnu.org ReportedBy: eggert@gnu.org Consider this C program: #if 9223372036854775807 < 0 #endif #if -1 - 9223372036854775807 < 0 #endif #if -1 - (-1 - 9223372036854775807) < 0 #endif When compiled with GCC (x86-64), GCC 4.7.2 warns: t.c:5:37: warning: integer overflow in preprocessor expression [enabled by default] The warning is incorrect, since there is no overflow in this program. Evidently GCC's preprocessor computes A-B by first negating B, and then adding the result to A. This causes GCC to incorrectly report overflow when B is the minimum possible integer and A is negative, because in this case -B overflows even though A-B does not overflow.
next reply other threads:[~2012-12-17 7:23 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-17 7:23 eggert at gnu dot org [this message] 2013-12-10 1:23 ` [Bug preprocessor/55715] " jsm28 at gcc dot gnu.org 2013-12-10 1:25 ` jsm28 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-55715-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).