Created on 2014-09-08.00:00:00 last changed 3 months ago
Additional notes (August, 2024)
According to the resolution of issue 2721, storage for the elements of buf is considered reused and thus the lifetime of those elements ends when the allocation function returns. Out-of-lifetime objects cannot hold values.
Given the following example,
#include <new> int main() { unsigned char buf[sizeof(int)] = {}; int *ip = new (buf) int; return *ip; // 0 or undefined? }
Should the preceding initializsation of the buffer carry over to the value of *ip? According to 6.7.4 [basic.indet] paragraph 1,
When storage for an object with automatic or dynamic storage duration is obtained, the object has an indeterminate value, and if no initialization is performed for the object, that object retains an indeterminate value until that value is replaced (7.6.19 [expr.ass]).
In this case, no new storage is being obtained for the int object created by the new-expression.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-08-22 11:33:28 | admin | set | messages: + msg7807 |
2024-08-22 11:33:28 | admin | set | status: drafting -> drwp |
2014-09-08 00:00:00 | admin | create |