From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12451 invoked by alias); 3 Feb 2003 16:45:28 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 12269 invoked from network); 3 Feb 2003 16:45:27 -0000 Received: from unknown (HELO kontiki.ito.tu-darmstadt.de) (130.83.198.42) by 172.16.49.205 with SMTP; 3 Feb 2003 16:45:27 -0000 Received: from gin (gin.internal [10.2.0.251]) by kontiki.ito.tu-darmstadt.de (Postfix) with SMTP id 5A20B27C70; Mon, 3 Feb 2003 17:45:26 +0100 (CET) Received: by gin (sSMTP sendmail emulation); Mon, 3 Feb 2003 17:45:26 +0100 From: "Wesley W. Terpstra" Date: Mon, 03 Feb 2003 16:45:00 -0000 To: gcc@gcc.gnu.org Cc: Bonzini Subject: Re: Warnings for unhandled c++ exceptions? Message-ID: <20030203164526.GA26049@ito.tu-darmstadt.de> References: <002601c2cb78$2a3efbc0$29dd1d97@bonz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002601c2cb78$2a3efbc0$29dd1d97@bonz> User-Agent: Mutt/1.3.28i X-SW-Source: 2003-02/txt/msg00087.txt.bz2 On Mon, Feb 03, 2003 at 12:34:06PM +0100, Bonzini wrote: > > int foo() throw (int) > > { > > throw "this will abort -- why? I broke my promise, but no warning..."; > > } > > ... > > catch (const char *s) > > A warning might be desirable, but it is not an odd behavior, as the purpose > of the throw clause (aka exception specification) is exactly to abort if an > exception that's not mentioned there propagates above it. Ahh. That makes sense. That is at least some guarantee. > Anyway I don't think the warning should be enabled by default as wide bodies > of C++ code don't use exception specifications. I never suggested is as a default. I suggested an optional flag to be used for compiler-assisted bug-tracking and quality code writing. (refer to the earlier portion of the message) ... especially since most (all?) of these errors are visible at compile-time. Perhaps there should be two flags: -Wthrow-clause-violated If a method throws an exception which is not listed in it's throw () clause, or calls a method whose throw clause is not handled or not included, generate a warning. -Wthrow-clause-missing If a method throws an exception or calls a method which declares a throw clause, but has no throw-clause itself, a warning is generated. Implies -Wthrow-clause-violated I only suggest this if some does not already have a patch floating around. I presume someone else has already requested this functionality? google didn't turn up much because the keywords are ambiguous. --- Wes