struct foo {
int val;
void func() {}
};
int main() {
int foo::* ptr1 = &(foo::val);
void (foo::* ptr2)() = &(foo::func);
}
Diagnostic messages of this code are "invalid use of non-static data member 'val'" (line 6) and "call to non-static member function without an object argument" (line 7). (clang 18.1.0, https://godbolt.org/z/YhGvWrTTb)
These messages can be more clear like "cannot form pointer to member from a parenthesized expression".
```cpp
struct foo {
int val;
void func() {}
};
int main() {
int foo::* ptr1 = &(foo::val);
void (foo::* ptr2)() = &(foo::func);
}
```
Diagnostic messages of this code are "invalid use of non-static data member 'val'" (line 6) and "call to non-static member function without an object argument" (line 7). (clang 18.1.0, <https://godbolt.org/z/YhGvWrTTb>)
These messages can be more clear like "cannot form pointer to member from a parenthesized expression".
Diagnostic messages of this code are "invalid use of non-static data member 'val'" (line 6) and "call to non-static member function without an object argument" (line 7). (clang 18.1.0, https://godbolt.org/z/YhGvWrTTb)
These messages can be more clear like "cannot form pointer to member from a parenthesized expression".