You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CWG3026 [expr.unary.op] Wording is ambiguous: Pointer to member of which class? #705
If the operand is a qualified-id naming a non-static or variant member m of some class C, other than an explicit object member function, the result has type “pointer to member of class C of type T” and designates C::m.
In the above:
x is a variant member both of the anonymous union and of A, and
y is a non-static member of both A and of B.
It seems C in the wording is not quite unique.
Suggested resolution:
If the operand is a qualified-id naming a non-static or variant class member m of some class C, other than an explicit object member function, then let C be
the class of which m is a direct member if m is not a variant member, and otherwise
the class, that is not an anonymous union, of which m is a variant member.
The the 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 ([expr.prim.id.general]) and cannot be used to form a pointer to member.]
changed the title [-][section.label] Proposed issue title[/-][+][expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/+]on May 11, 2025
changed the title [-][expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/-][+]CWG3026 [expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/+]on May 11, 2025
I think we can remove the comma before "other than an explicit object member function".
Can we retain a little more of the less awkward incoming phrasing by saying
If the operand is a qualified-id naming a non-static direct member m of some class C, where C is not an anonymous union, ... (old text)...
My attempt:
If the operand is a qualified-id naming a non-static direct member m, other than an explicit object member function, of some class C, ignoring anonymous union classes, the result has type “pointer to member of class C of type T” and designates C::m.
The implicit undefined behaviour I mentioned on the reflector re: P2996 (Reflection) will then instead manifest in the next bullet.
Activity
[-][section.label] Proposed issue title[/-][+][expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/+]jensmaurer commentedon May 11, 2025
CWG3026
[-][expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/-][+]CWG3026 [expr.unary.op] Wording is ambiguous: Pointer to member of which class?[/+]hubert-reinterpretcast commentedon May 11, 2025
@jensmaurer, the binding of "
m" to mean the class member disappeared in the CWG3026 version of the resolution.jensmaurer commentedon May 11, 2025
Thanks, fixed.
hubert-reinterpretcast commentedon May 11, 2025
Because direct members of anonymous unions are also direct members of their enclosing class (if any) (https://wg21.link/class.mem.general#3),
can be simplified to
jensmaurer commentedon May 12, 2025
Yeah. I've fixed that. Can we retain a little more of the less awkward incoming phrasing by saying
hubert-reinterpretcast commentedon May 13, 2025
I think we can remove the comma before "other than an explicit object member function".
My attempt:
The implicit undefined behaviour I mentioned on the reflector re: P2996 (Reflection) will then instead manifest in the next bullet.
jensmaurer commentedon Aug 9, 2026
Resolved by paper P2996R13.