Is the code below represented "undefined behavior" according to C ++ 11 (due to the use of const_cast, see quote below)
const void* p = operator new(123);
operator delete(const_cast<void*>(p));
Corresponding quote from the C ++ 11 standard (3.7.4.2.3):
The value of the first argument provided to the release function may be a null pointer value; if so, and if the release function is included in the standard library, the call has no effect. Otherwise, the behavior will not be determined if the value specified in operator delete(void*)the standard library is not one of the values returned by the previous call either operator new(std::size_t)or operator new(std::size_t, const std::nothrow_t&)in the standard library
If the answer is no, specify quotation marks from the C ++ 11 standard that confirm this.
source
share