public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results
@ 2010-10-25 17:44 sjbespa at comcast dot net
  2010-10-25 18:45 ` [Bug fortran/46166] " dominiq at lps dot ens.fr
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: sjbespa at comcast dot net @ 2010-10-25 17:44 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/46166] optimization and/or removing an if(.false.) statement leads to bad results
  2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
@ 2010-10-25 18:45 ` dominiq at lps dot ens.fr
  2010-10-25 18:51 ` kargl at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2010-10-25 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2010-10-25 18:45:18 UTC ---
1) Remove the Tabs from your source.
(2) Compile with  -O2 -Wall -Wuninitialized -fcheck=all.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/46166] optimization and/or removing an if(.false.) statement leads to bad results
  2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2010-10-25 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org 2010-10-25 18:50:56 UTC ---
Have you thought about using -Wall and fixing
the issue with tauc?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/46166] optimization and/or removing an if(.false.) statement leads to bad results
  2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
  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
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-26 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org

--- Comment #3 from janus at gcc dot gnu.org 2010-10-26 15:00:51 UTC ---
I think it would be helpful if you could reduce your test case (which is a
total mess right now) to something more reasonable. Otherwise it's very hard to
decide whether it is a compiler problem or a user problem and to pin down where
the differences at -O0/-O1 come from.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/46166] optimization and/or removing an if(.false.) statement leads to bad results
  2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2010-10-26 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2010-10-26 15:09:37 UTC ---
Janus,

See comment #2.  The problem is tauc is used
before it is initialized.  This is a bogus
bug report.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/46166] optimization and/or removing an if(.false.) statement leads to bad results
  2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
                   ` (3 preceding siblings ...)
  2010-10-26 15:09 ` sgk at troutmask dot apl.washington.edu
@ 2010-10-26 15:13 ` janus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-26 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from janus at gcc dot gnu.org 2010-10-26 15:13:14 UTC ---
(In reply to comment #4)
> The problem is tauc is used
> before it is initialized.  This is a bogus
> bug report.

Why don't we just close it then?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-10-26 15:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 17:44 [Bug fortran/46166] New: optimization and/or removing an if(.false.) statement leads to bad results sjbespa at comcast dot net
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

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).