This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/43716] [4.6 Regression] Revision 158105 miscompiles doduc.f90
- From: "mkuvyrkov at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Apr 2010 19:32:19 -0000
- Subject: [Bug tree-optimization/43716] [4.6 Regression] Revision 158105 miscompiles doduc.f90
- References: <bug-43716-12313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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