[Bug c/52209] New: wrong code at -O0

regehr at cs dot utah.edu gcc-bugzilla@gcc.gnu.org
Sat Feb 11 03:56:00 GMT 2012


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

             Bug #: 52209
           Summary: wrong code at -O0
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: regehr@cs.utah.edu
                CC: chenyang@cs.utah.edu


[regehr@gamow 2]$ icc -Wall small.c
[regehr@gamow 2]$ ./a.out 
-1
[regehr@gamow 2]$ clang -Wall small.c
[regehr@gamow 2]$ ./a.out 
-1
[regehr@gamow 2]$ current-gcc -O0 small.c
[regehr@gamow 2]$ ./a.out 
1
[regehr@gamow 2]$ current-gcc -O1 small.c
[regehr@gamow 2]$ ./a.out 
-1
[regehr@gamow 2]$ cat small.c
int printf (const char *, ...);

struct S0
{
  int f2:1;
};

static struct S0 c;

int b;

int main (void)
{
  b = -1 ^ c.f2;
  printf ("%d\n", b);
  return 0;
}
[regehr@gamow 2]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r184082-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.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-r184082-install
--program-prefix=r184082- --enable-languages=c,c++
Thread model: posix
gcc version 4.7.0 20120210 (experimental) (GCC)



More information about the Gcc-bugs mailing list