From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14933 invoked by alias); 25 Oct 2010 17:44:38 -0000 Received: (qmail 14922 invoked by uid 22791); 25 Oct 2010 17:44:37 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Oct 2010 17:44:31 +0000 From: "sjbespa at comcast dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sjbespa at comcast dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 25 Oct 2010 17:44:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02074.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: sjbespa@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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!