https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87628
--- Comment #5 from AK <hiraditya at msn dot com> --- As per: https://en.cppreference.com/w/cpp/memory/new/operator_delete """ In all cases, if ptr is a null pointer, the standard library deallocation functions do nothing. If the pointer passed to the standard library deallocation function was not obtained from the corresponding standard library allocation function, the behavior is undefined. """ So it should be fine to remove the check `if(p)`