Adrian
Adrian

Reputation: 10911

Is this noexcept declaration valid?

struct X
{
    void f() noexcept(noexcept(g()));
    void g() noexcept;
};

In vc++ and clang, this works, but gcc is complaining:

source_file.cpp:6:34: error: ‘g’ was not declared in this scope
     void f() noexcept(noexcept(g()));
                                  ^

I'm thinking that this is a bug in gcc and not a feature in the others. Is that correct?

Upvotes: 2

Views: 58

Answers (1)

Your assessment is correct

Within the class member-specification, the class is regarded as complete within function bodies, default arguments, noexcept-specifiers, and default member initializers (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.

In the scope of a complete type, g should be found by unqualified name lookup.

Upvotes: 4

Related Questions