18 Feb
2022
18 Feb
'22
4:36 p.m.
Andrey Semashev wrote:
What std::launder is intended to be is a fence for compiler speculations as to the possible value in the dereferenced location. That is, in the following example:
alignas(int) unsigned char storage[sizeof(int)]; int* p1 = new (storage) int(1); float* p2 = new (storage) float(2.0f); int* p3 = new (storage) int(3); std::printf("%d\n", *p1);
the program is allowed to print 1...
I don't think it is. The "will automatically apply to the new object" clause applies (even in its C++14 form) and all its requirements seem to be met. https://eel.is/c++draft/basic.life#8