Bug 32119

Summary: g++ does not check exception-specifications
Product: [Retired] Red Hat Linux Reporter: Wagner T. Correa <wtcorrea>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: hopper, wtcorrea
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-07 12:28:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Wagner T. Correa 2001-03-18 07:03:55 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.2.16-22smp i686)


When a function specifies the exceptions that it may throw, the compiler
can check if a caller is either handling the exceptions or throwing them
too. g++ does not check that.

Reproducible: Always
Steps to Reproduce:
#include <exception>

void foo() throw (exception)
{
        throw exception();
}

int main()
{
        foo(); // should get a warning here
        return 0;
}


Actual Results:  The program above compiles without any warning and
dumps core when run.


Expected Results:  The program should still compile, but g++ should give a
warning that the exception is not being handled, so the programmer could
create a try block and handle it more gracefully than simply dumping core.

Comment 1 Omnifarious 2001-07-02 20:23:10 UTC
Also:

void foo() throw(int)
{
    throw "Fred";
}

should also generate a warning.


Comment 2 Jakub Jelinek 2004-10-07 12:28:44 UTC
This is an enhancement request that should have been filed upstream.
See http://gcc.gnu.org/bugzilla/