constexpr static member pointer compiles with gcc and clang, but not with MSVC

Viewed 99

The following class

class Foo
{
    int member;
    inline static constexpr auto r = &Foo::member;
};

compiles with gcc 10.2 and clang 11.0.0. However, trying to compile the same code with MSVC v19.28 results in following error:

error C2327: 'Foo::member': is not a type name, static, or enumerator
error C2065: 'member': undeclared identifier

Is this a compiler bug or am I running into undefined behavior? All compilers have been run in C++17 mode. (https://godbolt.org/z/Gv1KW7 on Compiler Explorer)

0 Answers
Related