[class.cdtor] p2 needs changes/notes to clarify intent and limitations
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[class.cdtor] p2 needs a note to clarify its limitations.
Bugs which lead back to this paragraph
GCC contributers have falsely interpreted this paragraph to mean that this can be marked __restrict. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82899. A more detailed explanation for why this reading is incorrect can be found here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110912.
Proposed Solution (1/2)
- I think the wording should be made more conventional, by using the term "value computation" instead of saying "the value ... thus obtained".
- Only scalar type objects can be accessed [defns.access] Note 1, so any object which has subobjects cannot be accessed.
During the construction of an object, if the value of
-the object or
any of its subobjects is accessed through a glvalue that is not obtained, directly or indirectly,
from the constructor's this pointer,
-the value of the object or subobject thus obtained is unspecified.
+the value computation of this subobject yields an unspecified value.
Proposed Solution (2/2)
Furthermore, it may be beneficial to add a note which clarifies that a side effect on the subobjects through such a glvalue will have the expected effect. The attached example could also include a case such as:
struct S {
int x;
S(int &r) {
r = 0; // if r refers to S::x, then this is equivalent to x = 0
}
};
S s(s.x);
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 [class.cdtor] paragraph 2 in the C++ draft and read the linked [defns.access] note. Review GCC bug reports 82899 and 110912, then evaluate the two proposed wording changes and the suggested S example. Done means the paragraph's limitations and intended interpretation are clarified in the draft.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100