A static member function can access an incomplete member of a type

I found the following code to fail in gcc but compile to clang .

struct S
{
    int foo();
    static auto bar() -> decltype(std::declval<S>().foo());
    void baz(decltype(bar()));
};

      

Based on a similar example in this thread , I would expect the code to fail because it S

is an incomplete type within its scope, but I'm not sure if there is a special rule for static functions.

+3


source to share





All Articles