This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/85374] New: Confusing diagnostic for function with missing brace that looks like a function-try-block
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 12 Apr 2018 11:10:17 +0000
- Subject: [Bug c++/85374] New: Confusing diagnostic for function with missing brace that looks like a function-try-block
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85374
Bug ID: 85374
Summary: Confusing diagnostic for function with missing brace
that looks like a function-try-block
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
I had a function that originally looked like:
int func(int some, int params, int blah) {
and I removed the parameters, unintentionally also removing the opening brace
at the end of the line, to give:
int func()
// Oops, opening brace missing
try {
throw 1;
}
catch (...) {
return 0;
}
return 1;
}
a.cc:9:5: error: expected unqualified-id before 'return'
return 1;
^~~~~~
a.cc:10:1: error: expected declaration before '}' token
}
^
Clang does a bit better by saying "extraneous closing brace":
a.cc:9:5: error: expected unqualified-id
return 1;
^
a.cc:10:1: error: extraneous closing brace ('}')
}
^
2 errors generated.
I couldn't figure out what was wrong with the code from GCC's error, and only
saw the problem after trying to compile it with Clang.