The program which will be attached demonstrates a case where, when the -fstrict-aliasing optimization is turned on, the result of the final one of 6 double-to-float conversions does not get written to memory as it should. According to valgrind (memory debugging tool), the target memory gets left uninitialized.
The expected output and actual output are described in the program's comments. I don't think I have done any illegal pointer aliasing in this program, and the -Wstrict-aliasing=2 option doesn't warn of any such errors. The problem occurs in g++ 4.1.2. It does not occur in older versions I tried (4.0.2, 3.3.5) nor at lower optimization levels. The compiler version info, as shown by g++ -v, is: Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --libdir=/usr/lib64 --libexecdir=/usr/lib64 --with-gxx-include-dir=/usr/include/c++/4.1.2 --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --without-system-libunwind --enable-spp --disable-libssp --enable-version-specific-runtime-libs --host=x86_64-suse-linux Thread model: posix gcc version 4.1.2 -- Summary: -fstrict-aliasing causes omission of double-to-float conversion Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dhatch at ilm dot com GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37679