4 ms·
> AFAIK placement new does launder. But both new and launder have no effect on their argument (well, placement new of course constructs an object there), they o
by saagarjha 7y ago
> AFAIK placement new does launder. But both new and launder have no effect on their argument (well, placement new of course constructs an object there), they only 'bless' pointer returned from it.
I may be misunderstanding, but this seems to directly contradict what the linked paper says:
> Note that std::launder() does not “white wash” the pointer for any further usage.
> The obvious question is, why don’t we simply fix the current memory model so that using data where placement new was called for implicitly always does launder?
- gpderetta 7y agoBecause the placement new might have been called in a other translation unit for example so the compiler can't track the it.
- gpderetta 7y ago> I may be misunderstanding, but this seems to directly contradict what the linked paper says: >> Note that std::launder() does not “white wash” the pointer for any further usage. no, it is consistent. Launder does not white wash its parameter, only its return pointer and any pointer returned by it. Same for placement new.