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

            Bug ID: 82388
           Summary: wrong code at -O1 and above on x86_64-linux-gnu in
                    32-bit mode
           Product: gcc
           Version: unknown
            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: ---

This might be related to PR 82387, which only manifests in the 64-bit mode,
while this one only in the 32-bit mode. 

$ gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20171001 (experimental) [trunk revision 253330] (GCC) 
$ 
$ gcctk -m32 -O0 small.c; ./a.out; echo $?
0
$ gcc-7.2.0 -m32 -O1 small.c; ./a.out; echo $?
0
$ 
$ gcctk -m32 -O1 small.c; ./a.out; echo $?
251
$ 


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


struct A
{
  int b;
  int c;
  int d;
} e;

struct A g ()
{
  struct A h[30] = {{0,0,0}};
  return h[29]; 
}

int main ()
{
  e = g ();
  return e.b; 
}

Reply via email to