[Bug c++/89513] constexpr functions with function try block shouldn't be accepted at least with -pedantic in -std=c++{11,14,17} modes
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 26 21:41:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89513
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-02-26
CC| |msebor at gcc dot gnu.org
Blocks| |55004
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. Clang 7 prints:
$ clang++ -S -Wall pr89513.C
pr89513.C:2:1: error: function try block not allowed in constexpr function
try {
^
pr89513.C:9:3: error: statement not allowed in constexpr function
try { return true; } catch (...) {}
^
2 errors generated.
The latest Clang with -Wall:
pr89513.C:3:1: warning: function try block in constexpr function is a C++2a
extension [-Wc++2a-extensions]
try {
^
pr89513.C:6:1: warning: control may reach end of non-void function
[-Wreturn-type]
}
^
pr89513.C:10:3: warning: use of this statement in a constexpr function is a
C++2a extension [-Wc++2a-extensions]
try { return true; } catch (...) {}
^
pr89513.C:14:16: warning: unused variable 'a' [-Wunused-const-variable]
constexpr auto a = foo ();
^
pr89513.C:15:16: warning: unused variable 'b' [-Wunused-const-variable]
constexpr auto b = bar ();
^
5 warnings generated.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues
More information about the Gcc-bugs
mailing list