[Bug c++/90731] New: regression - noexcept broken for forward declarations with decltype
v at vsamko dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 3 15:49:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90731
Bug ID: 90731
Summary: regression - noexcept broken for forward declarations
with decltype
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: v at vsamko dot com
Target Milestone: ---
void foo1() noexcept(true) {}
decltype(foo1) stub_foo1;
void stub_foo1() noexcept(true) {}
This compiles fine with clang 8 and gcc 8.3, but not with gcc 9.1 (all in c++17
mode).
g++ 9.1 produces error
<source>:9:6: error: declaration of 'void stub_foo1() noexcept' has a different
exception specifier
9 | void stub_foo1() noexcept(true) {}
| ^~~~~~~~~
<source>:7:16: note: from previous declaration 'void stub_foo1()'
7 | decltype(foo1) stub_foo1;
| ^~~~~~~~~
Compiler returned: 1
According to the standard
(https://en.cppreference.com/w/cpp/language/noexcept_spec) - Functions
differing only in their exception specification cannot be overloaded (just like
the return type, exception specification is part of function type, but not part
of the function signature) (since C++17).
And indeed,
void foo1() noexcept(true) {}
void foo2() noexcept(false) {}
std::is_same_v<decltype(foo1), decltype(foo2)> // evaluates to false
More information about the Gcc-bugs
mailing list