-
Notifications
You must be signed in to change notification settings - Fork 781
Open
Description
[expr.prim.id.general] p2 says:
If an id-expression E denotes a member M of an anonymous union ([class.union.anon]) U:
- If U is a non-static data member, E refers to M as a member of the lookup context of the terminal name of E (after any transformation to a class member access expression ([class.mfct.non.static])).
[Example 1: o.x is interpreted as o.u.x, where u names the anonymous union member. — end example]
IIUC, the intent of the first bullet actually means the id-expression that would denote the member of U
(conceptually designated by u.x
) will be reinterpreted as o.x
as if x
is the member of o
.
Consider this case:
struct A{
union {
int a;
};
void show(){
int c = this->a; // #1
}
};
The id-expression a
denotes the member a
of the anonymous union, and the terminal name of a
is a
, whose lookup context is just A
, as per [basic.lookup.qual.general] p2. Hence, the intent of the rule may want to say a
is interpreted as the member of A
.
However, the note conveys a converse meaning with the intent, I think.
Metadata
Metadata
Assignees
Labels
No labels