This is the mail archive of the
mailing list for the GNU Fortran project.
Wrong (?) optimisation with gfortran 4.8.1 svn
- From: Sylvestre Ledru <sylvestre at debian dot org>
- To: fortran at gcc dot gnu dot org
- Cc: Calixte Denizet <calixte dot denizet at scilab-enterprises dot com>, Matthias Klose <doko at debian dot org>
- Date: Mon, 26 Aug 2013 11:02:28 +0200
- Subject: Wrong (?) optimisation with gfortran 4.8.1 svn
- Authentication-results: sourceware.org; auth=none
- References: <521B08F8 dot 50602 at debian dot org>
Using gfortran 4.8.1-9 from Debian (this package also includes svn
modifications to r201764), I am getting an unexpected optimization on
Sorry, I haven't been able to produce a test case which shows this issue.
With this code:
if (st*(stk(l)-e2).gt.0.0d+0) then
compiling with this specific release of gfortran with -O2, the declaration
will return -2 while it should return 1
stk double precision
Here are some contexts:
n = 0
52 if (st*(stk(l)-e2).gt.0.0d+0) then
go to 53
n = n+1
l = l+1
stk(l) = e1 + dble(n)*ste
go to 52
When adding a print *,st*(stk(l)-e2 in the if clause, I got -2 (so -2 is
greater than 0) !
Using -O0 fixes the issue.
Please note that printing the variable fixes also the issue.
If needed, the full file can be seen here:
I am available to test.
PS: please C/C me, I am not subscribed.