[expr.prim.id.general] p2 The first note in the rule is a bit misleading
Nobody has claimed this yet.
- #6225 by @eisenwave — closed without merging
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with [expr.prim.id.general] p2, the quoted first bullet, and Example 1, then compare them with the A::show example in this issue. Revise the note so it does not suggest the converse interpretation of the rule, and verify that the wording matches the intended treatment of the anonymous-union member.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100