Compiler version: Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)
System: Linux tethys 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i686 athlon i386 GNU/Linux Code that illustrates the problem #include <cstdio> double ulongToDouble(unsigned long lval) { double work = 1.0; ((long *)&work)[1] |= lval & 0x000fffff; ((long *)&work)[0] |= lval & 0xfff00000 | 0x00080000; return work - 1.0; } int main(int argc, char **args) { printf("%27.20f \n", ulongToDouble(0xffffffffUL)); printf("%27.20f \n", ulongToDouble(0)); return 1; } Unoptimized, correct output: [EMAIL PROTECTED] workspace]$ g++ -Wall bug.cpp [EMAIL PROTECTED] workspace]$ ./a.out 0.99999999988358467817 0.00000000011641532183 Optimized: [EMAIL PROTECTED] workspace]$ g++ -Wall -O2 bug.cpp [EMAIL PROTECTED] workspace]$ ./a.out 0.00000000000000000000 0.00000000000000000000 Do you really want the bug.ii file? It is rather lengthy and I don't see how to attach it. Chuck -- Summary: code that compiles and runs correctly with no optimization but code optimizes to nothing. Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: charris208 at comcast dot net CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23961