public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49103] New: local variables exchange values / wrong code with -O3
@ 2011-05-21 17:54 thomas.orgis at awi dot de
  2011-05-21 18:50 ` [Bug fortran/49103] " dominiq at lps dot ens.fr
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: thomas.orgis at awi dot de @ 2011-05-21 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: local variables exchange values / wrong code with -O3
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thomas.orgis@awi.de
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


Created attachment 24321
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24321
test program exposing the bug

After upgrading to gfortran 4.6.0, I noticed crashes in my codebase. This seems
to boil down to some local messup of variable values. I observe this with -O3,
but not with -O2 plus all available flags that are included in -O3. So, this
must be one of the internal optimizations that are not accessible via
individual flags.

The example is ripped out of a larger codebase and it shows. I spent over a
whole day diagnosing and trimming down already. Hopefully, you will mainly have
to look at the lower 100 lines. The routine grid_faces is the point of
interest, with a call to base_new triggering the issue.

The bad example:

shell$ gfortran -O3 gcc46gridbug.f90
shell$ ./a.out 
 LOG: Coordinate mapping:           1           2           3
 LOG:       back mapping:           1           2           3
 LOG: Base point:   0.0000000000000000        0.0000000000000000       
0.0000000000000000     
 generating base functions
 grid: faces
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           1           1
 Compare the base grades:           1           1
 grades again           2           2
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           1           1
 Compare the base grades:           1           1
 grades again           2           2
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           1           1
 Compare the base grades:           1           1
 grades again           2           2
 grid finished
 PASS


And the good example:

shell$ gfortran -O2 gcc46gridbug.f90 
shell$ ./a.out 
 LOG: Coordinate mapping:           1           2           3
 LOG:       back mapping:           1           2           3
 LOG: Base point:   0.0000000000000000        0.0000000000000000       
0.0000000000000000     
 generating base functions
 grid: faces
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 grades again           2           2
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 grades again           2           2
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 Here is the bug. The grades should be (2 2):           2           2
 Compare the base grades:           1           1
 grades again           2           2
 grid finished
 PASS

The code worked with gcc 4.3.3 and 4.5.1, as well as the intel compiler 11.1. I
hesitate to count in open64 and the sun/oracle compilers as, while they might
not show this bug, they have enough others that stopped me from using them:-/

If this still should be an error on my side, I'd appreciate to be enlightened.


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

end of thread, other threads:[~2011-06-14 22:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-21 17:54 [Bug fortran/49103] New: local variables exchange values / wrong code with -O3 thomas.orgis at awi dot de
2011-05-21 18:50 ` [Bug fortran/49103] " dominiq at lps dot ens.fr
2011-05-21 21:37 ` [Bug fortran/49103] [4.6/4.7 Regression] " dominiq at lps dot ens.fr
2011-05-21 22:07 ` dominiq at lps dot ens.fr
2011-05-21 23:29 ` dominiq at lps dot ens.fr
2011-05-22 11:12 ` rguenth at gcc dot gnu.org
2011-05-22 11:22 ` dominiq at lps dot ens.fr
2011-05-23  7:59 ` jakub at gcc dot gnu.org
2011-05-28 11:28 ` dominiq at lps dot ens.fr
2011-05-28 11:29 ` burnus at gcc dot gnu.org
2011-05-28 18:05 ` dominiq at lps dot ens.fr
2011-05-31 11:59 ` jakub at gcc dot gnu.org
2011-05-31 13:40 ` jakub at gcc dot gnu.org
2011-06-12 13:44 ` rguenth at gcc dot gnu.org
2011-06-13  8:43 ` burnus at gcc dot gnu.org
2011-06-14 15:27 ` jakub at gcc dot gnu.org
2011-06-14 15:29 ` jakub at gcc dot gnu.org
2011-06-14 22:17 ` jakub 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).