[Bug tree-optimization/43716] [4.6 Regression] Revision 158105 miscompiles doduc.f90
mkuvyrkov at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Apr 13 19:32:00 GMT 2010
------- Comment #13 from mkuvyrkov at gcc dot gnu dot org 2010-04-13 19:32 -------
The SIGSEGV is due to -funsafe-math-optimizations being used with code like:
==
Re = eps*debm*DIAhy/(vis*sec)
reo = Re
IF ( Re.LT.1000. ) THEN
i1 = INT(Re/200.) + 1
ELSEIF ( Re.LT.4000. ) THEN
i1 = INT(Re/500.) + 4
ELSEIF ( Re.LT.10000. ) THEN
i1 = INT(Re/2000.) + 10
ELSEIF ( Re.GE.30000. ) THEN
IF ( Re.GE.49999. ) Re = 49999.D+00
i1 = INT(Re/10000.) + 16
ELSE
i1 = INT(Re/5000.) + 13
ENDIF
i2 = i1 + 1
y1 = y(i1)
y2 = y(i2)
==
Here we have index `i1' calculated from fp values and then casted to int.
Segmentation fault occurs in `y1 = y(i1)' with i1 equal to 0xffffffff8000000c.
This is in function S00061 in doduc_red.f90, not in s33022.f90.
Also, to trigger the SIGSEGV it is necessary to compile both doduc_red.f90 and
s33022.f90 with "-O3 -funsafe-math-optimizations -ffinite-math-only". If
either of the modules is compiled with -O2 the SIGSEGV does not occur.
While I will not argue that my patch is 100% bug-free, this seems to be an
invalid testcase.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43716
More information about the Gcc-bugs
mailing list