http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57663
Bug ID: 57663 Summary: Arithmetic error with -fPIC -O Product: gcc Version: 4.6.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: bardeau at iram dot fr Created attachment 30328 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30328&action=edit Print is incorrect with gfortran 4.6.4 Dear gfortran developers, the attached Fortran program fails to make a correct comparison and then prints an erroneous value if compiled as follows with gfortran 4.6.4: home/bardeau> gfortran -fPIC -O test.f90 -o test && ./test >>> -5.71989641833856102E-002 This is true for gfortran 4.6.3 and 4.6.4 with options -fPIC and -O. gfortran 4.7.0 and above do not seem affected. Under normal conditions, the printout should be: home/bardeau> gfortran test.f90 -o test && ./test >>> 0.20000000000000001 I use gfortran 4.6.4 which I compiled myself (see below). However, I was first reported this bug under Ubuntu 12.04.2 LTS 64 bit with gfortran 4.6.3-1ubuntu5. It seems that the gcc 4.6 branch is still receiving bug fixes, so could you have a look? Thank you, Sebastien home/bardeau> uname -a Linux bardeau 2.6.32-358.2.1.el6.x86_64 #1 SMP Tue Mar 12 14:18:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux home/bardeau> gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/home/bardeau/Softs/gcc-4.6.4/libexec/gcc/x86_64-unknown-linux-gnu/4.6.4/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --with-gmp=/home/bardeau/Softs --prefix=/home/bardeau/Softs/gcc-4.6.4 --enable-languages=c,c++,fortran Thread model: posix gcc version 4.6.4 (GCC)