The result of the division of 18446744065119617024llu by the result of (1<<31)
is wrong on a 32bit platform.
Reproduce: gcc s.c && ./a.out
should have exit code 0 but doesn't.
Expected: gcc -DEXPECTED s.c && ./a.out
has exit code 0 as expected.
gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)
[lxbuild021] /afs/cern.ch/user/a/axel/tmp/gccconv >
/afs/cern.ch/sw/lcg/contrib/gcc/4.1.2/slc4_ia32_gcc34/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /build/LCG/gcc-4.1.2/configure
--prefix=/afs/cern.ch/sw/lcg/contrib/gcc/4.1.2/slc4_ia32_gcc34
Thread model: posix
gcc version 4.1.2
uname -a
Linux lxbuild021.cern.ch 2.6.9-42.0.10.EL.cernsmp #1 SMP Thu Mar 1 15:11:46 CET
2007 i686 i686 i386 GNU/Linux
I'll give the .c instead of .i because it shows the expected result and has no
#includes:
int main (){
unsigned long long a = 18446744065119617024llu;
/* results expected to be identical */
#ifdef EXPECTED
int b = ((int)(1<<31));
a = a / b;
#else
a = a / ((int)(1<<31));
#endif
return a;
}
--
Summary: unsigned long long operator << and integer literals
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at axel-naumann dot de
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32324