Calling delete on original buffer of char type after casting .c++
问题 in this answer: https://stackoverflow.com/a/222578/4416169 with this code: char *buf = new char[sizeof(string)]; // pre-allocated buffer string *p = new (buf) string("hi"); // placement new string *q = new string("hi"); // ordinary heap allocation there is a comment that says: keep in mind that the strings are destrcuted manually before deleting the buffer, thats what the comment below already assumes. Strictly, it's undefined behaviour to call delete[] on the original char buffer. Using