This is the mail archive of the
fortran@gcc.gnu.org
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>
Hello,
Using gfortran 4.8.1-9 from Debian (this package also includes svn
modifications to r201764), I am getting an unexpected optimization on
gfortran code.
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
st*(stk(l)-e2)
will return -2 while it should return 1
st=1,e1=8,e2=11
stk double precision
st double
Here are some contexts:
n = 0
l=l1
52 if (st*(stk(l)-e2).gt.0.0d+0) then
go to 53
endif
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:
http://cgit.scilab.org/cgit.cgi/scilab/tree/scilab/modules/double/sci_gateway/fortran/vecimpl.f
I am available to test.
Regards,
Sylvestre
PS: please C/C me, I am not subscribed.