I don't think there's anything wrong with the testcase.  The -O2 result is
wrong.

[reg...@gamow ~]$ current-gcc -v

Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r164319-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r164319-install
--program-prefix=r164319- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20100915 (experimental) (GCC) 

[reg...@gamow ~]$ current-gcc -O1 small.c -o small
[reg...@gamow ~]$ ./small 
1
[reg...@gamow ~]$ current-gcc -O2 small.c -o small
[reg...@gamow ~]$ ./small 
0
[reg...@gamow ~]$ cat small.c

int printf(const char *format, ...);

static int g_7;
static int *volatile g_6 = &g_7;

static int func_53(int *p_58)
{
    return *p_58;
}

int main(void)
{
    *g_6 = 1;
    printf("%d\n", func_53(&g_7));
    return 0;
}


-- 
           Summary: possible wrong code bug
           Product: gcc
           Version: unknown
            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: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to