This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-05-12
(From submission #705.)
Consider:
struct A { union { int x; }; int y; }; struct B : A {}; template <typename> struct Q; template <> struct Q<A> {}; template <typename T> Q<T> f(int T::*); Q<A> g() { return f(&B::x); } // OK Q<A> h() { return f(&B::y); } // OK
For both cases, the pointer to member is of type "pointer to member of class A", but the wording is not clear.
Suggested resolution:
Change in 7.6.2.2 [expr.unary.op] bullet 3.1 as follows:
The operand of the unary & operator shall be an lvalue of some type T.
- If the operand is a qualified-id naming a non-static
or variantclass member mof some class C, other than an explicit object member function, then let C be the class, that is not an anonymous union, of which m is a direct member.theThe result has type “pointer to member of class C of type T” and designates C::m. [Note: A qualified-id that names a member of a namespace-scope anonymous union is considered to be a class member access expression (7.5.5.1 [expr.prim.id.general]) and thus cannot be used to form a pointer to member.-- end note]- ...