User account creation filtered due to spam.

Bug 58344 - [4.9 Regression] ICE with segfault at -O1 and above on x86_64-linux-gnu
Summary: [4.9 Regression] ICE with segfault at -O1 and above on x86_64-linux-gnu
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.9.0
: P1 normal
Target Milestone: 4.9.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on: 58346
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-07 04:01 UTC by Zhendong Su
Modified: 2014-01-16 21:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-09-09 00:00:00


Attachments
gcc49-pr58344.patch (772 bytes, patch)
2014-01-16 14:19 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2013-09-07 04:01:59 UTC
The following code causes an ICE when compiled with the current gcc trunk at -O1 and above on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.8.x. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++,objc,obj-c++,fortran,lto --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20130906 (experimental) [trunk revision 202308] (GCC) 
$ gcc-trunk -O0 -c small.c
$ gcc-4.8 -O1 -c small.c
$ gcc-trunk -O1 -c small.c
small.c: In function ‘foo’:
small.c:9:7: internal compiler error: Segmentation fault
   bar (a[0]);
       ^
0x924b2f crash_signal
	../../gcc-trunk/gcc/toplev.c:335
0x6daba0 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**)
	../../gcc-trunk/gcc/expr.c:9758
0x5fc8ca expand_expr
	../../gcc-trunk/gcc/expr.h:444
0x5fc8ca store_one_arg
	../../gcc-trunk/gcc/calls.c:4502
0x6024f2 expand_call(tree_node*, rtx_def*, int)
	../../gcc-trunk/gcc/calls.c:3042
0x6dbc2e expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**)
	../../gcc-trunk/gcc/expr.c:10234
0x612b6f expand_call_stmt
	../../gcc-trunk/gcc/cfgexpand.c:2180
0x612b6f expand_gimple_stmt_1
	../../gcc-trunk/gcc/cfgexpand.c:2218
0x612b6f expand_gimple_stmt
	../../gcc-trunk/gcc/cfgexpand.c:2370
0x6139b3 expand_gimple_basic_block
	../../gcc-trunk/gcc/cfgexpand.c:4204
0x61557c gimple_expand_cfg
	../../gcc-trunk/gcc/cfgexpand.c:4723
0x61557c execute
	../../gcc-trunk/gcc/cfgexpand.c:4937
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-----------------------------------


struct U {};

static struct U a[1];

extern void bar (struct U);

void foo ()
{
  bar (a[0]);
}
Comment 1 Richard Biener 2013-09-09 08:37:35 UTC
Confirmed, related to 58346
Comment 2 Jakub Jelinek 2013-12-19 13:20:18 UTC
Started with r200211.
Comment 3 Jakub Jelinek 2014-01-16 14:19:42 UTC
Created attachment 31854 [details]
gcc49-pr58344.patch

Untested fix.
Comment 4 Jakub Jelinek 2014-01-16 19:54:54 UTC
Author: jakub
Date: Thu Jan 16 19:54:23 2014
New Revision: 206685

URL: http://gcc.gnu.org/viewcvs?rev=206685&root=gcc&view=rev
Log:
	PR middle-end/58344
	* expr.c (expand_expr_real_1): Handle init == NULL_TREE.

	* gcc.c-torture/compile/pr58344.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr58344.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jeffrey A. Law 2014-01-16 21:13:50 UTC
FIxed by jakub's commit.