This is already allowed today, you don't need to change the standard. It's not*required* by the standard because it adds a store that is usually redundant, but compilers could offer an option to do this.
As others have pointed out, doing that is unlikely to prevent very many bugs in practice.
Use after free, double free...etc will be more like to be caught in code
{
m_ptr = new T;
// if all the following take m_ptr by reference
inspect_maybe_free(m_ptr);
transform_maybe_free(m_ptr);
maybe_free(m_ptr);
// i can detect if delete was called before.
if(m_ptr) delete m_ptr;
}
With the current implementation, you cannot do this.
That doesn't matter. Zeroing the pointer can be done by the delete operator, not by the `operator delete` function.