Question
MSVC rejects program with member function call while gcc and clang accept
I wrote the following program in C++23 that compiles with gcc and clang but is rejected by msvc. I want to know is this well-formed or ill-formed etc as per the standard. Live demo
struct C
{
void f(this C);
void b()
{
(C::f)(); //compiles in gcc and clang but msvc rejects
}
};
int main()
{
C c;
c.b();
}
MSVC says:
<source>(7): error C2352: 'C::f': a call of a non-static member function requires an object
<source>(3): note: see declaration of 'C::f'