http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46166

           Summary: optimization and/or removing an if(.false.) statement
                    leads to bad results
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: sjbe...@comcast.net


Created attachment 22147
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22147
example program described in bug report

On Mac OS X 10.6.4, with gfortran from recent sources on the 4.6 trunk:

et:new.single.v2 sjbespa$ /volumes/dev/gfortran-4.6-trunk/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/volumes/dev/gfortran-4.6-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/Volumes/dev/gfortran-4.6-trunk/bin/../libexec/gcc/x86_64-apple-darwin10/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: ../gfortran-4.6-src/configure
--prefix=/volumes/dev/gfortran-4.6-trunk --enable-languages=fortran
--host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
--target=x86_64-apple-darwin10
Thread model: posix
gcc version 4.6.0 20101013 (experimental) (GCC) 

the following bug(s) have been observed:

(1) if the attached file is compiled as follows

sjbespa$ /volumes/dev/gfortran-4.6-trunk/bin/gfortran  -O0 driver.f90
sjbespa$ ./a.out

and run, the program executes correctly. The output is shown in example 1.

(2) if the optimization level is changed to -O1 or higher:

sjbespa$ /volumes/dev/gfortran-4.6-trunk/bin/gfortran  -O1 driver.f90
sjbespa$ ./a.out

the program doesn't run correctly as shown in example 2. It appears that the
variables fcurr and flast have invalid values.

(3) finally, if the if statement beginning at statement 251 is commented out,
the example program fails in the same manner as in (2) independent of the
optimization level.


**** example 1 ****

sjbespa$ /volumes/dev/gfortran-4.6-trunk/bin/gfortran  -O0 driver.f90
 sjbespa$ ./a.out
  input data for constitutive model solver                              
 rhosat =    40743665431535.492     
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 rho                1000000.0000000000     
 plStrainInv        0.0000000000000000     
 plStrainInvLast    0.0000000000000000     
 plStrainInvRate    0.0000000000000000     
 dlamba             0.0000000000000000     
 fcurr             -9999999.9999000002     
 flast             -9999999.9999000002     
   215.99849824095310        0.0000000000000000       6.95322298958717986E-310
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 rho                1000000.0000000000     
 plStrainInv        0.0000000000000000     
 plStrainInvLast    0.0000000000000000     
 plStrainInvRate    0.0000000000000000     
 dlamba             0.0000000000000000     
 fcurr             -9999999.9999000002     
 flast             -9999999.9999000002     
   863.99399296381239        0.0000000000000000       6.95322298958717986E-310


**** example 2 *****

 sjbespa$ /volumes/dev/gfortran-4.6-trunk/bin/gfortran  -O1 driver.f90
sjbespa$ ./a.out
  input data for constitutive model solver                              
 rhosat =    40743665431535.492     
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 rho                1000000.0000000000     
 plStrainInv        0.0000000000000000     
 plStrainInvLast    0.0000000000000000     
 plStrainInvRate    0.0000000000000000     
 dlamba             0.0000000000000000     
 fcurr             -9999999.9999000002     
 flast             -9999999.9999000002     
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 rho                1005087.5000000000     
 plStrainInv       9.99999999999999955E-007
 plStrainInvLast    0.0000000000000000     
 plStrainInvRate   9.99999999999999955E-007
 dlamba            9.99999999999999955E-007
 fcurr                                  NaN
 flast                                  NaN
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 rho                                    NaN
 plStrainInv                            NaN
 plStrainInvLast    0.0000000000000000     
 plStrainInvRate                        NaN
 dlamba                                 NaN
 fcurr                                  NaN
 flast                                  NaN
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reply via email to