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.
Created attachment 6925 [details] a test case which show the ice
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 bug?
I cannot reproduce the bug on i686-pc-linux-gnu neither. I think it's sparc specific. Here is the log % gcc -v -O2 -c bug.c Reading specs from /export/opt/pkg/gcc-3.4.1/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.1/specs 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 /export/opt/pkg/gcc-3.4.1/bin/../libexec/gcc/sparc-sun-solaris2.9/3.4.1/cc1 -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 /var/tmp//cckfRILf.s ignoring nonexistent directory "/export/opt/pkg/gcc-3.4.1/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.1/../../../../sparc-sun-solaris2.9/include" ignoring duplicate directory "/opt/pkg/gcc-3.4.1/lib/gcc/sparc-sun-solaris2.9/3.4.1/include" ignoring nonexistent directory "/opt/pkg/gcc-3.4.1/lib/gcc/sparc-sun-solaris2.9/3.4.1/../../../../sparc-sun-solaris2.9/include" #include "..." search starts here: #include <...> search starts here: /export/opt/pkg/gcc-3.4.1/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.1/include /usr/local/include /opt/pkg/gcc-3.4.1/include /usr/include 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:http://gcc.gnu.org/bugs.html> for instructions.
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) { default: 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
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 crash.
Postponed until GCC 3.4.3.
> 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.
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
Investigating.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00434.html>.
Subject: Bug 17027 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: ebotcazou@gcc.gnu.org 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. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.645&r2=2.2326.2.646 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfglayout.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.50.4.1&r2=1.50.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.103.2.5&r2=1.103.2.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.275&r2=1.3389.2.276 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/20041007-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Second patch applied.