System info: Debian Unstable, x86 (Transmeta Crusoe TM5800) The following program produces different output when compiled with and without optimisations. This didn't occur with gcc 4.0.3, it seems to be new with 4.1.0.
#include <stdio.h> int table[32][256]; int main(void) { int i, j; for (i = 0; i < 32; i++) for (j = 0; j < 256; j++) table[i][j] = ((signed char)j) * i; for (i = 0; i < 10; i++) printf("%10i %10i\n", table[i][5], table[i][132]); return 0; } Compiling without optimisations, the output is as desired. With -O1 the output changes. Here's how I can reproduce the problem: $ gcc-4.1 -o example.O0 example.c $ gcc-4.1 -O1 -o example.O1 example.c $ ./example.O0 0 0 5 -124 10 -248 15 -372 20 -496 25 -620 30 -744 35 -868 40 -992 45 -1116 $ ./example.O1 0 0 5 132 10 264 15 396 20 528 25 660 30 792 35 924 40 1056 45 1188 $ gcc-4.1 -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.0 (Debian 4.1.0-0) -- Summary: Computed (integer) table changes with -O Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kmshanah at disenchant dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26719