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

            Bug ID: 57568
           Summary: wrong code for assignment in conditional at -Os
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The following code is miscompiled by gcc trunk and 4.8 on x86_64-linux at -Os
and above optimization levels in 32-bit mode (should print nothing).  This is a
regression from 4.7.x.

$ gcc-trunk -v
gcc version 4.9.0 20130608 (experimental) [trunk revision 199849] (GCC) 
$ gcc-trunk -O1 -m32 reduced.c 
$ ./a.out 
$ gcc-4.7 -Os -m32 reduced.c 
$ ./a.out 
$ gcc-trunk -Os -m32 reduced.c 
$ ./a.out 
1
$
---------------
int printf (const char *, ...);

int a[6][9] = {};
int b = 1;
int *c = &a[3][5];

int main ()
{
  if (b)
    if (*c = *c + *c)
      printf ("%d\n", a[3][5]);

  return 0;
}

Reply via email to