Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++undefined behavior catalogSingle-choice MCQ

Which of the following is undefined behavior in C++ purely due to a rule about object lifetime and storage reuse, independent of any data value?

alignas(int) unsigned char buf[sizeof(int)]; int* p = new (buf) int(7); int* q = std::launder(reinterpret_cast<int*>(buf)); *q = 8;