| ▲ | jandrewrogers 3 hours ago | |||||||
There was already a legal way to achieve this that everyone should already have been using (laundering a pointer through a no-op memmove). Using reinterpret_cast here is a bug. The "start_lifetime_as" facility does one additional thing beyond providing a tidy standard name for the memory laundering incantation. Semantically it doesn't touch the memory whereas the no-op memmove intrinsically does. In practice, this makes little difference, since the compiler could see that the memmove was a no-op and optimized accordingly. | ||||||||
| ▲ | kevin_thibedeau 3 hours ago | parent | next [-] | |||||||
This still has unresolved alignment issues that blow up outside the amd64 ecosystem. | ||||||||
| ||||||||
| ▲ | szmarczak 2 hours ago | parent | prev [-] | |||||||
No because the object does not exist after std::launder. It only exists after std::start_lifetime_as. The bytes being there says nothing about the object, per the C++ standard. | ||||||||
| ||||||||