[dcl.init.aggr]/4.1 designated-initializer-list vs initializer-clause
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
For each explicitly initialized element:
- If the element is an anonymous union member and the initializer list is a brace-enclosed designated-initializer-list, the element is initialized by the designated-initializer-list { D }, where D is the designated-initializer-clause naming a member of the anonymous union member. There shall be only one such designated-initializer-clause.
How could designated-initializer-list be the form { D }? According to the grammar of designated-initializer-list, it should be the comma-separated list of .identifier brace-or-equal-initializer. The above rule seems to phrase the following example
struct C{
union {
int a;
};
};
C c = {{.a = 0}};
In this example, the corresponding initializer of the anonymous union member is the initializer-clasuse, which is a brace-enclosed designated-initializer-list. However, the formal example under [dcl.init.aggr]/4.1 is that
struct C {
union {
int a;
const char* p;
};
int x;
} c = { .a = 1, .x = 3 };
That is, the original intent of the above rule is used to phrase the case where the explicitly initialized element is an anonymous union member and the corresponding initializer is a designated-initializer-clause naming the member of it. Should we reword the rule to that
If the element is an anonymous union member and the initializer D is a designated-initializer-clause naming a member of the anonymous union member, the element is initialized by the initializer { D }. There shall be only one such designated-initializer-clause for the anonymous union member.
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
Read the wording and examples in [dcl.init.aggr]/4.1, focusing on the distinction between a designated-initializer-clause and a brace-enclosed designated-initializer-list. Done means the rule unambiguously describes the anonymous-union case and agrees with both examples.
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
- Clearly specified
- Newbie friendliness
- 35/100