[Bug fortran/52117] allocated arrays give incorrect results when used with RESHAPE in gcc v4.6.2

sphirshman at yahoo dot com gcc-bugzilla@gcc.gnu.org
Mon Feb 6 19:47:00 GMT 2012


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

--- Comment #4 from steven hirshman <sphirshman at yahoo dot com> 2012-02-06 19:45:53 UTC ---
Thanks. I tried the -std=f95 flag and it gave the same (wrong) answer as
without it, in the test code I sent you. What is not Fortran95 compatible with
the code snippet I sent you?




________________________________
From: burnus at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: sphirshman@yahoo.com 
Sent: Monday, February 6, 2012 12:45 PM
Subject: [Bug fortran/52117] allocated arrays give incorrect results when used
with RESHAPE in gcc v4.6.2

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-06
17:45:36 UTC ---
(In reply to comment #2)
> Thank you for the information. THe work-around works with the newer (4.6.2)
> compiler, but is unrecognized by older versions of gcc that are in use on
> - for example - NERSC computers.

Well, the bug is related to (re)allocation on assignment (a Fortran 2003
features), which is new in GCC 4.6. Thus, both the flag -f(no-)realloc-lhs but
also the bug is only in GCC 4.6 (and 4.7).

You could also use "-std=f95", which implies -fno-realloc-lhs with GCC 4.6/4.7
but is also supported in older gfortrans; however, you need to have a code
which follows Fortran 95 close enough to be compilable with that flag.


> Is there a FIX other than the workaround planned, that will be backwards
> compatible with older compilers?

The actual bug has been fixed on both the GCC 4.6 branch (on 2012-02-03) and on
the GCC 4.7 trunk (on 2012-02-02). Thus, if you have a newer version of GCC
4.6/4.7, you are also not affected. (Cf. the nightly build from
http://gcc.gnu.org/wiki/GFortranBinaries )

See bug 52012 for details.


> Also, the B(:) fails on some platforms, I'm told by some of my co-workers.

Can you provides more details? Using "B(:) =" prevents the (re)allocation of
the left-hand side and thus it should also prevent the bug.

In particular:
- How does it fail? At compile time? At run time? With which error?
- Which version/platform of the compiler are you using?
- Is that with the code of comment 0 with only "B = RESHAPE..." changed to
"B(:) = RESHAPE..." or is it for some other code?



More information about the Gcc-bugs mailing list