Created on 2025-02-26.00:00:00 last changed yesterday
Suggested resolution:
Change in 6.8.4 [basic.life] paragraph 7 as follows:
Before the lifetime of an object has started but after the storage which the object will occupy has been allocated [ Footnote: ...] or, after the lifetime of an object has ended and before the storage which the object occupied is reused or released, any pointer thatrepresents the address of the storage location where the object will be or was locatedpoints to the object may be used but only in limited ways. ...
(Split off from issue 3001.)
The out-of-lifetime rules mishandle this example:
int a;
int *p = &a;
*p = 1; // #1
new (p) int;
This code has undefined behavior because, according to the wording specifying "represents the address", p is used to access the pointed-to object at #1 before its lifetime starts in the following line.
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-09-13 07:51:53 | admin | set | messages: + msg8101 |
2025-02-26 00:00:00 | admin | create |