From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25436 invoked by alias); 1 Jun 2004 15:28:00 -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 25429 invoked by uid 48); 1 Jun 2004 15:27:59 -0000 Date: Tue, 01 Jun 2004 15:28:00 -0000 Message-ID: <20040601152759.25428.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040531075856.15745.wsf@fultondesigns.co.uk> References: <20040531075856.15745.wsf@fultondesigns.co.uk> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/15745] exception specification incorrectly changes the type of the exception thrown X-Bugzilla-Reason: CC X-SW-Source: 2004-06/txt/msg00095.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2004-06-01 15:27 ------- Confirmed. Here's a small testcase: ------------------- typedef int IntArray[10]; IntArray i; void test_array() #ifdef TEST throw (IntArray) #endif { throw i; } int main () { try { test_array(); } catch (IntArray) {} } ------------------ We get g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc ; ./a.out g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc -DTEST ; ./a.out terminate called after throwing an instance of 'int*' Aborted The point is that if we throw an exception that violates the exception specification, then it is converted into an unspec exception and we abort. However, since we can catch the exception that we throw in the main function if there is no exception specification on the function body, it seems as if the exception thrown is really of type IntArray and shouldn't violate the exception specification. I agree that this is confusing and looks like a bug in gcc associated with decaying arrays to pointers, though I'd like to solicit a second opinion on this. We get the same results for all gcc versions from 2.95 to mainline. W. -- What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Known to fail| |2.95.3 3.3.1 3.0.4 3.4.0 | |3.5.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15745