This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/71909] New: g++ accepts an unreachable function catch block that lacks a corresponding try
- From: "db0451 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 17 Jul 2016 10:45:05 +0000
- Subject: [Bug c++/71909] New: g++ accepts an unreachable function catch block that lacks a corresponding try
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71909
Bug ID: 71909
Summary: g++ accepts an unreachable function catch block that
lacks a corresponding try
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: db0451 at gmail dot com
Target Milestone: ---
via http://stackoverflow.com/questions/38415131
The Standard requires a function-try block to have a corresponding
post-function catch block and vice-versa. But g++ will merrily compile the
following without saying anything, even with -std=c++14 -Wall -Wextra
-Wpedantic
struct foo
{
void bar()
{
}
catch (...)
{
}
};
int main ()
{
foo f;
f.bar();
return 0;
}
I presume the parser never checks for this case - somewhat understandable as
function-try is rare enough even when it _is_ used properly - but g++ should
generate an error on this code because it is not well-formed.