From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14991 invoked by alias); 7 Nov 2002 00:03:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14984 invoked from network); 7 Nov 2002 00:03:09 -0000 Received: from unknown (HELO mx2.redhat.com) (12.150.115.133) by sources.redhat.com with SMTP; 7 Nov 2002 00:03:09 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.11.6/8.11.6) with ESMTP id gA701aP28095; Wed, 6 Nov 2002 19:01:36 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gA7038l30961; Wed, 6 Nov 2002 19:03:08 -0500 Received: from localhost.localdomain (frothingslosh.sfbay.redhat.com [172.16.24.27]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id gA7037D09445; Wed, 6 Nov 2002 16:03:07 -0800 Received: (from rth@localhost) by localhost.localdomain (8.11.6/8.11.6) id gA7037J22660; Wed, 6 Nov 2002 16:03:07 -0800 X-Authentication-Warning: localhost.localdomain: rth set sender to rth@redhat.com using -f Date: Wed, 06 Nov 2002 16:03:00 -0000 From: Richard Henderson To: Mark Mitchell Cc: Jakub Jelinek , Aldy Hernandez , "gcc-patches@gcc.gnu.org" , "jason@redhat.com" Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests Message-ID: <20021107000307.GQ22215@redhat.com> Mail-Followup-To: Richard Henderson , Mark Mitchell , Jakub Jelinek , Aldy Hernandez , "gcc-patches@gcc.gnu.org" , "jason@redhat.com" References: <20021106124304.G10988@devserv.devel.redhat.com> <8450000.1036625540@warlock.codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8450000.1036625540@warlock.codesourcery.com> User-Agent: Mutt/1.4i X-SW-Source: 2002-11/txt/msg00377.txt.bz2 On Wed, Nov 06, 2002 at 03:32:20PM -0800, Mark Mitchell wrote: > There is nothing you can do with try/finally in C++ you can't already > do: > > try { X } finally { Y } > > can always be replaced with either of: > > (1) try { X } catch (...) { Y; throw; } Y; > > or: > > (2) { struct S { ~S() { Y } } s; X } > > depending on your stylistic preference. True. I was simply trying to make things easier for the thread library in having one macro work for both languages. > I do not think we should add exception support of any kind to GNU C; use > C++ if you want exceptions. See elsewhere about resistance compiling libc with a c++ compiler. The main problem is that you simply cannot implement cleanups with a few calls to a runtime library. There are data structures that the compiler must set up related to how it generated code. > If we do want to check these patches in, the semantics should be given > in terms of translation to (1) above. I don't agree with this. The EH ABI clearly distingishes between cleanups and catches. Thus the semantics are exactly those of (2), and not those of (1) at all. Indeed, even ISO C++ makes this distinction with std::uncaught_exception. Further, try/catch/rethrow does not express what happens when you use goto/break/continue/return to leave the try block. r~