https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105351
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2022-05-03
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot
gnu.org
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Er, the real reason the above works is because the type auto* of dummy's
template parameter demands that the argument &T::attr2 is an ordinary pointer,
not a pointer to member, which implies that it's a static member.
We should also be able to check that attr2 is a static member via
template<auto> struct dummy;
template<typename T>
concept C = requires(T v) {
v.attr1;
typename dummy<T::attr2>;
v.fun1();
T::fun2();
};
which Clang is happy with, but GCC incorrectly emits an error during SFINAE:
<source>: In substitution of 'template<class auto:1> requires C<auto:1> auto
f(auto:1) [with auto:1 = Z]':
<source>:48:5: required from here
<source>:9:14: error: invalid use of non-static data member 'Z::attr2'
9 | typename dummy<T::attr2>;
| ~~~~~~~~~^~~~~~~~~~~~~~~~
<source>:39:15: note: declared here
39 | const int attr2 = 0;
| ^~~~~
This is definitely a bug.