From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6931 invoked by alias); 13 Apr 2010 19:32:44 -0000 Received: (qmail 6866 invoked by uid 48); 13 Apr 2010 19:32:19 -0000 Date: Tue, 13 Apr 2010 19:32:00 -0000 Message-ID: <20100413193219.6865.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/43716] [4.6 Regression] Revision 158105 miscompiles doduc.f90 In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mkuvyrkov at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg01319.txt.bz2 ------- 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