https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70919

            Bug ID: 70919
           Summary: wrong code at -O1 on x86_64-linux-gnu in 32-bit mode
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The current gcc trunk miscompiles the following code on x86_64-linux-gnu at -O1
(only) in the 32-bit mode (but on in 64-bit mode).  


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160502 (experimental) [trunk revision 235731] (GCC) 
$ 
$ gcc-trunk -m32 -O0 small.c; ./a.out
$ gcc-trunk -m64 -O1 small.c; ./a.out
$ 
$ gcc-trunk -m32 -O1 small.c
$ ./a.out
Aborted (core dumped)
$ 


-------------------------------------------


#pragma pack(1)
struct S0
{
  int f0:24;
};

struct S1
{
  int f1;
} a; 

int b, c;

char
fn1 (struct S1 p1)
{
  return 0;
}

int
main ()
{
  c = fn1 (a);
  if (b)
    {
      struct S0 f[3][9] =
        { { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
          { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
          { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } }
        };
      b = f[1][8].f0;
    }
  struct S0 g[3][9] = 
        { { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
          { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
          { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } }
        };

  if (g[1][8].f0 != 1)
    __builtin_abort (); 

  return 0; 
}

Reply via email to