Article View: gnu.gcc.bug
Article #1013GCC 2.2.2 incorrectly multiplies some long long constants by 3
From: Paul Eggert
Date: Sat, 29 Aug 1992 08:32
Date: Sat, 29 Aug 1992 08:32
33 lines
1458 bytes
1458 bytes
GCC 2.2.2 (Sparc, SunOS 4.1.2) incorrectly multiplies some long long
constants by 3. In the following example program, GCC miscomputes c3's
initial value to be 4294967294 instead of the correct value 8589934590,
so the program incorrectly exits with status 1.
#define C 2863311530LL
long long int c = C;
long long int c3 = C * 3;
main() { return c*3 != c3; }
Here is a workaround.
===================================================================
RCS file: fold-const.c,v
retrieving revision 2.2.2.3
diff -c -r2.2.2.3 fold-const.c
*** fold-const.c 1992/08/11 04:23:35 2.2.2.3
--- fold-const.c 1992/08/29 08:21:30
***************
*** 1045,1055 ****
int2h = int2h * 2 + (temp < int2l);
t = build_int_2 (temp, int2h);
goto got_it;
- case 3:
- temp = int2l + int2l + int2l;
- int2h = int2h * 3 + (temp < int2l);
- t = build_int_2 (temp, int2h);
- goto got_it;
case 4:
temp = int2l + int2l;
int2h = int2h * 4 + ((temp < int2l) << 1);
--- 1045,1050 ----
Technical Details
Message-ID:
<9208290832.AA13653@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Subject: GCC 2.2.2 incorrectly multiplies some long long constants by 3 Message-ID: <9208290832.AA13653@farside.twinsun.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sat, 29 Aug 1992 08:32:48 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 34