This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


1800. Pointer to member of nested anonymous union

Section: 7.6.2.2  [expr.unary.op]     Status: CD4     Submitter: Richard Smith     Date: 2013-10-22

[Moved to DR at the November, 2014 meeting.]

According to 7.6.2.2 [expr.unary.op] paragraph 3,

The result of the unary & operator is a pointer to its operand. The operand shall be an lvalue or a qualified-id. If the operand is a qualified-id naming a non-static member m of some class C with type T, the result has type “pointer to member of class C of type T” and is a prvalue designating C::m.

It is not clear whether this wording applies to variant members of C (i.e., members of nested anonymous unions) or only to its non-variant members. For example, given

  struct A { union { int n; }; };
  auto x = &A::n;

should the type of x be int A::* or int A::anon::*? Current implementations choose the former.

Proposed resolution (February, 2014):

Change 7.6.2.2 [expr.unary.op] paragraph 3 as follows:

The result of the unary & operator is a pointer to its operand. The operand shall be an lvalue or a qualified-id. If the operand is a qualified-id naming a non-static or variant member m of some class C with type T, the result has type “pointer to member of class C of type T” and is a prvalue designating C::m. Otherwise...