public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sjbespa at comcast dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results
Date: Mon, 25 Oct 2010 17:44:00 -0000	[thread overview]
Message-ID: <bug-46166-4@http.gcc.gnu.org/bugzilla/> (raw)

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
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


             reply	other threads:[~2010-10-25 17:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-25 17:44 sjbespa at comcast dot net [this message]
2010-10-25 18:45 ` [Bug fortran/46166] " dominiq at lps dot ens.fr
2010-10-25 18:51 ` kargl at gcc dot gnu.org
2010-10-26 15:01 ` janus at gcc dot gnu.org
2010-10-26 15:09 ` sgk at troutmask dot apl.washington.edu
2010-10-26 15:13 ` janus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-46166-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).