Example in [allocator.requirements.general] incorrectly uses launder?
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
From https://stackoverflow.com/q/66755218
[tab:cpp17.allocator] has the following example added by p0593r6:
When reusing storage denoted by some pointer value
p,launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)]))can be used to implicitly create a suitable array object and obtain a pointer to it.
If T is not an implicit-lifetime type, then, even if an object of type T[m ≤ n] is created, the lifetimes of the array elements are not started, which means launder's preconditions are violated:
Preconditions:
prepresents the addressAof a byte in memory. An objectXthat is within its lifetime and whose type is similar toTis located at the addressA.
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 the [allocator.requirements.general] example linked in the issue and compare it with the cited launder preconditions and P0593R6 wording. Review the linked Stack Overflow discussion and the existing comments for the lifetime concern and any proposed resolution. Done when the standard example is resolved with wording that satisfies the applicable preconditions.
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