User account creation filtered due to spam.

Bug 17027 - [3.4 regression] ICE with noreturn function in loop at -O2
Summary: [3.4 regression] ICE with noreturn function in loop at -O2
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.3
Assignee: Eric Botcazou
Keywords: ice-on-valid-code, patch
Depends on:
Reported: 2004-08-14 15:14 UTC by dbk
Modified: 2004-10-07 06:13 UTC (History)
2 users (show)

See Also:
Host: sparc-sun-solaris2.9
Target: sparc-sun-solaris2.9
Build: sparc-sun-solaris2.9
Known to work: 3.3 4.0.0
Known to fail: 3.4.0 3.4.1 3.4.2
Last reconfirmed: 2004-08-17 09:08:58

a test case which show the ice (235 bytes, text/plain)
2004-08-14 15:17 UTC, dbk

Note You need to log in before you can comment on or make changes to this bug.
Description dbk 2004-08-14 15:14:17 UTC
the ice only occurs when the code is compiled with -O2. Other values for -O don't
give the ice.
This bug is also in 3.4.0.
Gcc 3.3 compiles fine.
Comment 1 dbk 2004-08-14 15:17:20 UTC
Created attachment 6925 [details]
a test case which show the ice
Comment 2 Giovanni Bajo 2004-08-16 10:38:40 UTC
I cannot reproduce this with any compiler on i686-pc-linux-gnu, maybe is it 
target specific?

DBK, would you please post the compiler log (adding -v to the command line)?

Eric, I guess that if this is a sparc-specific bug, you can easily confirm this 
Comment 3 dbk 2004-08-16 14:04:52 UTC
I cannot reproduce the bug on i686-pc-linux-gnu neither. I think  it's sparc
Here is the log
 % gcc -v -O2 -c bug.c
Reading specs from
Configured with: ../configure --prefix=/opt/pkg/gcc-3.4.1 --disable-nls
--with-cpu=v9 --enable-languages=c,c++
Thread model: posix
gcc version 3.4.1
-quiet -v -iprefix
/export/opt/pkg/gcc-3.4.1/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.1/ -D__sparcv8
bug.c -quiet -dumpbase bug.c -mcpu=v9 -auxbase bug -O2 -version -o
ignoring nonexistent directory
ignoring duplicate directory
ignoring nonexistent directory
#include "..." search starts here:
#include <...> search starts here:
End of search list.
GNU C version 3.4.1 (sparc-sun-solaris2.9)
        compiled by GNU C version 3.4.1.
GGC heuristics: --param ggc-min-expand=56 --param ggc-min-heapsize=49152
bug.c: In function `main':
bug.c:22: internal compiler error: Segmentation Fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:> for instructions.
Comment 4 Christian Ehrhardt 2004-08-17 09:08:56 UTC
I can confirm this on sparc-sun-solaris2.9. It requires -mcpu=v9
though which is interesting because the crash seems to happen in
apparently arch independant code (see backtrace below):

I use the following cleaned up testcase:

/* Compile with -O2 -mcpu=v9 */
int bar(void);
void baz (void)  __attribute__ ((noreturn)); /* noreturn is required */
int foo;

void f (void) 
        while (bar ()) {
                switch (1) {
                        baz ();

Program received signal SIGSEGV, Segmentation fault.
0x000a8928 in cfg_layout_finalize () at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/cfglayout.c:869
869             c = c->rbi->next;
(gdb) bt
#0  0x000a8928 in cfg_layout_finalize () at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/cfglayout.c:869
#1  0x002b268c in reorder_basic_blocks (flags=100) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/bb-reorder.c:1115
#2  0x00267c70 in rest_of_compilation (decl=0xff172500) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/toplev.c:2332
#3  0x002abcf8 in tree_rest_of_compilation (fndecl=0xff172500, nested_p=false) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/tree-optimize.c:168
#4  0x00031c18 in c_expand_body_1 (fndecl=0xff172500, nested_p=0) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/c-decl.c:6158
#5  0x002add28 in cgraph_expand_function (node=0xff172980) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/cgraphunit.c:538
#6  0x002afc70 in cgraph_optimize () at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/cgraphunit.c:1542
#7  0x0006d310 in c_objc_common_finish_file () at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/c-objc-common.c:245
#8  0x0026932c in toplev_main (argc=3845120, argv=0x3ab000) at /home/thales/ehrhardt/gcc-3.4-cvs/gcc/gcc/toplev.c

Comment 5 Andrew Pinski 2004-08-17 09:22:44 UTC
This is most likely a latent bug on the mainline also but as far as I can tell there is no way to hit this 
Comment 6 Mark Mitchell 2004-08-29 18:12:09 UTC
Postponed until GCC 3.4.3.
Comment 7 Mark Mitchell 2004-08-29 18:14:46 UTC
Postponed until GCC 3.4.3.
Comment 8 Eric Botcazou 2004-09-03 14:45:51 UTC
> Eric, I guess that if this is a sparc-specific bug, you can easily confirm this 
> bug?

Sure, although a bit late it seems :-)  Note that I don't need to specify -mcpu
to get the SIGSEGV.
Comment 9 Christian Ehrhardt 2004-09-03 14:56:08 UTC
Subject: Re:  [3.4 Regression] ICE with noreturn function in loop at -O2

On Fri, Sep 03, 2004 at 02:45:56PM -0000, ebotcazou at gcc dot gnu dot org wrote:
> Note that I don't need to specify -mcpu to get the SIGSEGV.

Indeed. The original testcase (first attachment) does require -mcpu=v9
to trigger the ICE here whereas the simplified version (comment #4) doesn't.

    regards  Christian

Comment 10 Eric Botcazou 2004-10-03 14:52:51 UTC
Comment 11 Andrew Pinski 2004-10-05 20:58:51 UTC
Patch here: <>.
Comment 12 CVS Commits 2004-10-07 06:12:14 UTC
Subject: Bug 17027

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	2004-10-07 06:12:02

Modified files:
	gcc            : ChangeLog cfglayout.c cfgrtl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: 20041007-1.c 

Log message:
	PR rtl-optimization/17027
	Backport from mainline:
	* cfglayout.c (fixup_fallthru_exit_predecessor): If the first block
	falls through to exit, split it.
	* cfgrtl.c (rtl_split_block): If no insn is specified, split on the
	first insn in the basic block.


Comment 13 Eric Botcazou 2004-10-07 06:13:20 UTC
Second patch applied.