The program below looks to me like it should print "0".

reg...@john-home:~$ current-gcc -O small.c -o small
reg...@john-home:~$ ./small
1
reg...@john-home:~$ cat small.c
extern int printf (__const char *__restrict __format, ...);

static int g_16[1];

static int *g_135 = &g_16[0];
static int *l_15 = &g_16[0];

static void foo (void)
{
  g_16[0] = 1;
  *g_135 = 0;
  *g_135 = *l_15;
  printf("%d\n", g_16[0]);
}

int main(void)
{
   foo();
   return 0;
} 
reg...@john-home:~$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/home/regehr/z/tmp/gcc-r156486-install/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/tmp/gcc-r156486-install --program-prefix=r156486-
--enable-languages=c,c++
Thread model: posix
gcc version 4.5.0 20100204 (experimental) (GCC)


-- 
           Summary: possible integer wrong code bug
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: regehr at cs dot utah dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952

Reply via email to