Why doesn’t GCC optimize out deletion of null pointers in C++?
According to C++14 [expr.delete]/7: If the value of the operand of the delete-expression is not a null pointer value, then: [ …omitted… ] Otherwise, it is unspecified whether the deallocation function will be called. So both compilers do comply with the standard, because it’s unspecified whether operator delete is called for deletion of a null … Read more