From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7559 invoked by alias); 2 Jun 2003 21:56:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7524 invoked by uid 48); 2 Jun 2003 21:56:21 -0000 Date: Mon, 02 Jun 2003 21:56:00 -0000 From: "afu@fugmann.dhs.org" To: gcc-bugs@gcc.gnu.org Message-ID: <20030602215620.11069.afu@fugmann.dhs.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/11069] New: C++ Standard Violation (15.3.3) X-Bugzilla-Reason: CC X-SW-Source: 2003-06/txt/msg00404.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11069 Summary: C++ Standard Violation (15.3.3) Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: major Priority: P2 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: afu@fugmann.dhs.org CC: gcc-bugs@gcc.gnu.org When thowing an object it seems that the type of the variable thrown is used and not the type of the object thrown in the catch block. This menas that exception are not caught correctly, and that it is impossible to destruct the thrown object correctly. To reproduce the bug, compile and run the following program: #include using namespace std; class Exception { public: Exception() { cout << "Constructor called" << endl; } virtual ~Exception() { cout << "Destructor called" << endl; } }; class ExtendedException: public Exception { public: ExtendedException(): Exception() { cout << "EE Constructor called" << endl; } ~ExtendedException() { cout << "EE Destructor called" << endl; } }; int main() { try { Exception *e = new ExtendedException(); throw (*e); } catch (ExtendedException &ee) { cout << "Caught ExtendedException" << endl; } catch (Exception &e) { cout << "Caught Exception" << endl; } } Expected result: Constructor called EE Constructor called Caught ExtendedException EE Destructor called Destructor called Got result: Constructor called EE Constructor called Caught Exception Destructor called Changing the type of *e to ExtendedException produces the expected result. ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.