Platform: Fedora release 8 (Werewolf) Linux chevy.lbl.gov 2.6.23.15-137.fc8 #1 SMP Sun Feb 10 17:03:13 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
% g++ -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /net/chevy/raid1/rwgk/gcc_trunk/configure --prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_141361_fc8_x86_64 --enable-languages=c,c++,fortran Thread model: posix gcc version 4.4.0 20081025 (experimental) (GCC) Problematic C++ code fragment: rot_mx proper_r = r; int proper_order = type_; if (proper_order < 0) { std::cout << "A branch" << std::endl; proper_order *= -1; proper_r = -proper_r; } if (proper_order > 1) { std::cout << "B branch" << std::endl; ... } Compiled with (just to show optimization options; please ignore the rest): g++ -o cctbx/sgtbx/rot_mx_info.o -c -fno-strict-aliasing -fPIC -ftemplate-depth-120 -w -DNDEBUG -O3 -ffast-math -fno-associative-math -ftrapping-math -DBOOST_DISABLE_THREADS -fopenmp -Iinclude -I/net/chevy/raid1/rwgk/hot/include -I/net/chevy/raid1/rwgk/as_in_cvs/include "-I/net/chevy/raid1/rwgk/hot/b u f/include" -I/net/chevy/raid1/rwgk/as_in_cvs -I/net/chevy/raid1/rwgk/hot/boost /net/chevy/raid1/rwgk/as_in_cvs/cctbx/sgtbx/rot_mx_info.cpp Given type_ = -2, the print statements should show A branch B branch but only "B branch" is actually shown. I can work around this problem either by compiling without optimizations, or by replacing the code above with: rot_mx proper_r; int proper_order; if (type_ < 0) { std::cout << "A branch" << std::endl; proper_order = -type_; proper_r = -r; } else { std::cout << "A else branch" << std::endl; proper_order = type_; proper_r = r; } if (proper_order > 1) { std::cout << "B branch" << std::endl; ... } I tried to reduce the problem, but it turns out to be tricky. The code above is part of a shared library (.so). Simply moving it into the same translation unit as the calling code makes the error go away. Before I spend more time on this, does the problem look familiar? (I.e. could it be that this bug was reported already?) I could give you a self-contained but very large reproducer. This would enable you to inspect the generated code, and maybe give us a clue how to construct a minimal reproducer. -- Summary: code generation error Product: gcc Version: 4.4.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=37922