Bug 32119 - g++ does not check exception-specifications
g++ does not check exception-specifications
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-03-18 02:03 EST by Wagner T. Correa
Modified: 2007-04-18 12:32 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-07 08:28:44 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Wagner T. Correa 2001-03-18 02:03:55 EST
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 16:23:10 EDT
Also:

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

should also generate a warning.
Comment 2 Jakub Jelinek 2004-10-07 08:28:44 EDT
This is an enhancement request that should have been filed upstream.
See http://gcc.gnu.org/bugzilla/

Note You need to log in before you can comment on or make changes to this bug.