Summary: | [3.3/3.4 regression] corruption in exception path, exception in returned expression | ||
---|---|---|---|
Product: | gcc | Reporter: | Colin Hirsch <gcc> |
Component: | target | Assignee: | Eric Botcazou <ebotcazou> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | ehrhardt, gcc-bugs, gcc |
Priority: | P1 | Keywords: | wrong-code |
Version: | 3.3.1 | ||
Target Milestone: | 3.3.2 | ||
Host: | sparc-sun-solaris2.8 | Target: | sparc-sun-solaris2.8 |
Build: | sparc-sun-solaris2.8 | Known to work: | |
Known to fail: | Last reconfirmed: | 2003-09-17 15:52:36 |
Description
Colin Hirsch
2003-09-16 13:57:53 UTC
I can't reproduce this on a linux box, so we need someone with a sparc. Christian? W. I can confirm the crash on sparc with recent 3.4. Apparently the value of debug in function cast_helper is not preserved accross the try block and the catch block tries to throw chunk. Here's a reduced self contained testcase that crashes on sparc if compiled with -O. Note that adding debug output sometimes makes the bug go away. // #include <iostream> struct S{ char * c; char data[100]; S () : c (data) {}; S (const S & s) { c = data; data[0] = s.c[0]; } }; S real_cast () { throw 3; } S cast_helper( S & debug ) { // std::cerr << &debug << std::endl; /* AAA */ try { return real_cast(); } catch ( int e) { // std::cerr << "HO " << &e << " "<< &debug << std::endl; throw debug; } } int main( ) { S tmp; try { cast_helper ( tmp ); } catch ( S & e ) { } return 0; } I can confirm the crash on GCC 3.2.2, 3.2.3, 3.3 and 3.3.2pre with Christian's testcase, but GCC 2.95.3 doesn't crash so we have a regression. Fixing. Subject: Bug 12301 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-09-21 08:17:48 Modified files: gcc : ChangeLog reorg.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/eh: delayslot1.C Log message: PR target/12301 * reorg.c (stop_search_p): Return 1 for insns that can throw internally. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1109&r2=2.1110 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/reorg.c.diff?cvsroot=gcc&r1=1.87&r2=1.88 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3074&r2=1.3075 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/eh/delayslot1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 Subject: Bug 12301 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: ebotcazou@gcc.gnu.org 2003-09-21 08:22:34 Modified files: gcc : ChangeLog reorg.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/eh: delayslot1.C Log message: PR target/12301 * reorg.c (stop_search_p): Return 1 for insns that can throw internally. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.748&r2=1.16114.2.749 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/reorg.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.82&r2=1.82.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.284&r2=1.2261.2.285 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/eh/delayslot1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1 |