Article View: gnu.gcc.bug
Article #49typo in fold-const.c prevents GCC 2.3.1 from catching some overflows
From: Paul Eggert
Date: Mon, 02 Nov 1992 23:54
Date: Mon, 02 Nov 1992 23:54
36 lines
1850 bytes
1850 bytes
GCC 2.3.1 (sparc, SunOS 4.1.2) doesn't warn about the integer overflow
in the program:
long long x = 9223372036854775807LL + 1;
due to a parenthesization typo (of mine, sorry!) in fold-const.c.
Here is a patch.
Mon Nov 2 23:51:14 1992 Paul Eggert (eggert@twinsun.com)
* fold-const.c (same_sign): Fix parenthesization typo.
===================================================================
RCS file: fold-const.c,v
retrieving revision 2.3
retrieving revision 2.3.1.1
diff -c -r2.3 -r2.3.1.1
*** fold-const.c 1992/10/21 21:14:52 2.3
--- fold-const.c 1992/11/02 23:51:14 2.3.1.1
***************
*** 62,68 ****
#define left_shift_overflows(a, b) ((a) != ((a) << (b)) >> (b))
/* Yield nonzero if A and B have the same sign. */
! #define same_sign(a, b) ((a) ^ (b) >= 0)
/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
--- 62,68 ----
#define left_shift_overflows(a, b) ((a) != ((a) << (b)) >> (b))
/* Yield nonzero if A and B have the same sign. */
! #define same_sign(a, b) (((a) ^ (b)) >= 0)
/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
Technical Details
Message-ID:
<9211022354.AA05259@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!iggy.GW.Vitalink.COM!cs.widener.edu!umn.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!iggy.GW.Vitalink.COM!cs.widener.edu!umn.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Newsgroups: gnu.gcc.bug Subject: typo in fold-const.c prevents GCC 2.3.1 from catching some overflows Message-ID: <9211022354.AA05259@farside.twinsun.com> Date: 2 Nov 92 23:54:39 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: Gnus Not Usenet Lines: 36 Approved: bug-gcc@prep.ai.mit.edu