https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91697
Bug ID: 91697
Summary: Cannot use this in noexcept specifier
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gccbugbjorn at fahller dot se
Target Milestone: ---
This C++11 code compiles with g++ 9.1, but fails with g++ versions 8, 7, 6, 5,
4.9, 4.8, and 4.7.
template <typename T>
void f(const T&) noexcept;
struct S
{
auto fr() const -> decltype(f(*this));
void fe() const noexcept(noexcept(f(*this)));
};
The compilation error is on the use of 'this' in the noexcept specifier for
S::fe().
The message is:
t.cpp:7:42: error: invalid use of 'this' at top level
void fe() const noexcept(noexcept(f(*this)));
^~~~
https://godbolt.org/z/NvNMZC
It looks similar to bug 91141, except this one does compile with g++-9.