[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csmith-dev] Bug in GCC LP64 targets


Csmith has generated the snippet below that reveals a bug in
so-called "LP64" GCC targets (64-bit longs and pointers, 32-bit ints).

#include <stdio.h>

signed char g_2 = (-6L);
int R;

  R = ((g_2 ^ 0U) <= (-4L));
  printf("long:%u int:%u R:%d\n", (unsigned)sizeof(long),
(unsigned)sizeof(int), R);
  return R;

All 64-bit versions of GCC I got my hands on print "long:8 int:4 R:1".
The specs of the latest version I tried are below.
I believe the correct output would be "8 4 0", the comparison being done
between longs, as in LP64, longs can contain all values represented
by unsigned ints.

Clang 1.0.2 from XCode 3.2.2 agrees with me.

Is this something that has already been reported?


$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)