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: unassig...@gcc.gnu.org ReportedBy: egg...@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.