public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/55715] New: bogus overflow warning for #if A-B when A<0 & B==minimum integer
@ 2012-12-17 7:23 eggert at gnu dot org
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
0 siblings, 2 replies; 3+ messages in thread
From: eggert at gnu dot org @ 2012-12-17 7:23 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug preprocessor/55715] bogus overflow warning for #if A-B when A<0 & B==minimum integer
2012-12-17 7:23 [Bug preprocessor/55715] New: bogus overflow warning for #if A-B when A<0 & B==minimum integer eggert at gnu dot org
@ 2013-12-10 1:23 ` jsm28 at gcc dot gnu.org
2013-12-10 1:25 ` jsm28 at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-12-10 1:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55715
--- Comment #1 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Author: jsm28
Date: Tue Dec 10 01:23:37 2013
New Revision: 205846
URL: http://gcc.gnu.org/viewcvs?rev=205846&root=gcc&view=rev
Log:
PR preprocessor/55715
libcpp:
* expr.c (num_binary_op): Implement subtraction directly rather
than with negation and falling through into addition case.
gcc/testsuite:
* gcc.dg/cpp/expr-overflow-1.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libcpp/ChangeLog
trunk/libcpp/expr.c
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug preprocessor/55715] bogus overflow warning for #if A-B when A<0 & B==minimum integer
2012-12-17 7:23 [Bug preprocessor/55715] New: bogus overflow warning for #if A-B when A<0 & B==minimum integer eggert at gnu dot org
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
1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-12-10 1:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55715
Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.9.0
--- Comment #2 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 4.9.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-10 1:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-17 7:23 [Bug preprocessor/55715] New: bogus overflow warning for #if A-B when A<0 & B==minimum integer eggert at gnu dot org
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
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).