(*) As far as I know the Standard allows an implementation to modify the operand of the delete
operator, however most implementations do not do that.
int* ptr = new int(0);
delete ptr; //delete is allowed to modify ptr, for example set it to 0
std::cout << ptr; // UB?
Acknowledging (*), is the reading of ptr
(in the form of printing it) well-defined?
If delete
does modify ptr
, is it allowed to set a trap value, which would make reading ptr
UB?