[Bug c++/66256] noexcept evaluation done before end of class

david at doublewise dot net gcc-bugzilla@gcc.gnu.org
Fri Aug 25 09:15:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66256

David Stone <david at doublewise dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david at doublewise dot net

--- Comment #8 from David Stone <david at doublewise dot net> ---
I do not believe that gcc is correct to reject this code. Consider

http://eel.is/c++draft/basic.scope.class#1

"The potential scope of a name declared in a class consists not only of the
declarative region following the name's point of declaration, but also of all
function bodies, default arguments, noexcept-specifiers, and
brace-or-equal-initializers of non-static data members in that class (including
such things in nested classes)."

That seems to state that this variable is in scope and thus this code should be
allowed.

As a second test case, this should also be accepted (same code, but with e put
in an unevaluated context instead of being static):


struct test
{
        test() noexcept(noexcept(e)) {}
        const bool e = false;
};

int main() {}




And also



struct test
{
        test() noexcept(noexcept(e())) {}
        const bool e() { return false; }
};

int main() {}


More information about the Gcc-bugs mailing list