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
c ++ c ++ 11


source to share


No one has answered this question yet

See similar questions:

2
How do I get the return type of a function in a class?

or similar:

951
Can a local memory variable be accessed outside of its scope?
33
Calling `this` member function from generic lambda clang vs gcc
eleven
Initializing a base class static constexpr data member using a derived class's static constexpr data member
8
Interaction between decltype and class member name shadowing external name
8
std :: async member function call
6
gcc does not accept package extension in default template argument
five
Aren't member functions of a template class compiling when instantiated?
3
std :: declval () firing assertion error with warnings in GCC
1
Declaring a static data member with decltype (auto) in C ++ 14
1
Can the templates function return type depend on the same function return type template recursively?



All Articles
Loading...
X
Show
Funny
Dev
Pics