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

            Bug ID: 58626
           Summary: possible array wrong code bug
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: regehr at cs dot utah.edu

[regehr@imp r106]$ gcc -O2 small.c ; ./a.out 
1
[regehr@imp r106]$ gcc -O3 small.c ; ./a.out 
0
[regehr@imp r106]$ cat small.c
int printf(const char *, ...);

int a[8][6] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
int b;

int main(void) 
{
  for (b = 0; b <= 1; b++) {
    a[1][3] = 0;
    int c;
    for (c = 0; c <= 1; c++) {
      a[c + 1][b] = a[c + 2][b];
    }
  }
  printf("%d\n", a[1][1]);
  return 0;
}
[regehr@imp r106]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/mnt/local/randomtest/compiler-install/gcc-r203223-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /users/regehr/z/compiler-source/gcc/configure
--prefix=/users/regehr/z/compiler-install/gcc-r203223-install
--enable-languages=c,c++ --enable-multilib
Thread model: posix
gcc version 4.9.0 20131005 (experimental) (GCC)

Reply via email to