Mixing operator new[] and placement new with ordinary delete[]
Just out of curiosity, is the following legal? X* p = static_cast<X*>(operator new[](3 * sizeof(X))); new(p + 0) X(); new(p + 1) X(); new(p + 2) X(); delete[] p; // Am I allowed to use delete[] here? Or is it undefined behavior? Similarly: X* q = new X[3](); (q + 2)->~X(); (q + 1)->~X(); (q + 0)->~X(); operator delete[](q); I'm pretty sure both give UB. §5.3.4/12 says the array form of a new expression may add some arbitrary amount of overhead to the amount of memory allocated. The array delete can/could then do something with the extra memory it expects to be there, but isn't since you didn't