Bug 37414 - [4.4 regression] ICE with -ffast-math
Summary: [4.4 regression] ICE with -ffast-math
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2008-09-07 22:23 UTC by Volker Reichelt
Modified: 2008-09-08 21:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-09-08 06:50:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-09-07 22:23:13 UTC
The following code snippet triggers an ICE on mainline (i686-pc-linux-gnu)#
when compiled with "-ffast-math":

=======================================
double foo(double x) { return x; }
double y = 2*foo(1);
=======================================

bug0.cc:2: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

The bug was introduced between 2008-08-23 and 2008-08-29.
Comment 1 Uroš Bizjak 2008-09-08 06:50:36 UTC
Confirmed:

Program received signal SIGSEGV, Segmentation fault.
0x082ac655 in optimize_function_for_speed_p (fun=0x0) at ../../gcc-svn/trunk/gcc/predict.c:205
/home/uros/gcc-svn/trunk/gcc/predict.c:205:6178:beg:0x82ac655
(gdb) bt
#0  0x082ac655 in optimize_function_for_speed_p (fun=0x0) at ../../gcc-svn/trunk/gcc/predict.c:205
#1  0x081f3c53 in fold_binary (code=MULT_EXPR, type=0xb7c4e478, op0=0xb7f56294, op1=0xb7cd39bc) at ../../gcc-svn/trunk/gcc/fold-const.c:10414
Comment 2 Jakub Jelinek 2008-09-08 21:31:50 UTC
Subject: Bug 37414

Author: jakub
Date: Mon Sep  8 21:30:23 2008
New Revision: 140122

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140122
Log:
	PR middle-end/37414
	* predict.c (optimize_function_for_size_p): Don't segfault if
	FUN is NULL.
	* fold-const.c (LOGICAL_OP_NON_SHORT_CIRCUIT, fold_truthop,
	tree_swap_operands_p): Don't test cfun != NULL before calling
	optimize_function_for_s*_p.

	* g++.dg/opt/init2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/init2.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/predict.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jakub Jelinek 2008-09-08 21:32:26 UTC
Fixed.