This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Wrong (?) optimisation with gfortran 4.8.1 svn


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]