I will attach a small reproducer. /* Reproducer for optimizer bug in gcc svn trunk revision 114570 (as checked out 2006_06_12_0834 PDT)
To produce correct output: g++ -Wall -O0 gcc_trunk_2006_06_12_0834_fc5_x86_64.cpp ./a.out To see the bug: g++ -Wall -O1 gcc_trunk_2006_06_12_0834_fc5_x86_64.cpp ./a.out Note the difference in the last line of the output: Correct: 1 0 0 Incorrect: 0 0 0 The output is also incorrect for -O2 and -O3. The last line of the output is correct if compiled with: g++ -Wall -O1 -DBAD_WORKAROUND gcc_trunk_2006_06_12_0834_fc5_x86_64.cpp ./a.out Platform: Fedora Core release 5 (Bordeaux) Linux rosie.lbl.gov 2.6.15-1.2054_FC5 #1 SMP Tue Mar 14 15:48:20 EST 2006 x 86_64 x86_64 x86_64 GNU/Linux % g++ -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /net/rosie/scratch1/rwgk/gcc_trunk/configure --prefix=/usr /local_cci/gcc_trunk_2006_06_12_0834_fc5_x86_64 --enable-languages=c,c++ Thread model: posix gcc version 4.2.0 20060612 (experimental) */ -- Summary: optimizer bug Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rwgk at yahoo dot com GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28003