Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.life] p2 says:
The lifetime of an object o of type T ends when:
- [...]
- the storage which the object occupies is released, or is reused by an object that is not nested within o ([intro.object]).
Consider this example:
alignas(int) unsigned char buffer[8];
int main() {
auto ptr = new (buffer) int{}; // #1
new (buffer) char{}; // #2
}
Assuming sizeof(int)==4, #1 starts the lifetime of an object of type int that occupies the storage with 4 bytes. However, #2 uses a part of the storage region, which only uses the head byte. Is the whole 4-byte storage considered to be reused?
Suggested Resolution:
Maybe we need to say that a storage is considered to be reused if any part of the storage is reused.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.life] p2 says:
Consider this example:
Assuming
sizeof(int)==4,#1starts the lifetime of an object of typeintthat occupies the storage with 4 bytes. However,#2uses a part of the storage region, which only uses the head byte. Is the whole 4-byte storage considered to be reused?Suggested Resolution:
Maybe we need to say that a storage is considered to be reused if any part of the storage is reused.