Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.compound] p5 says:
A pointer value P is valid in the context of an evaluation E if P is a pointer to function or a null pointer value, or if it is a pointer to or past the end of an object O and E happens before the end of the duration of the region of storage for O. If a pointer value P is used in an evaluation E and P is not valid in the context of E, then the behavior is undefined if E is an indirection ([expr.unary.op]) or an invocation of a deallocation function ([basic.stc.dynamic.deallocation])
[basic.stc.dynamic.deallocation] p5 says:
If the argument given to a deallocation function in the standard library is a pointer that is not the null pointer value ([basic.compound]), the deallocation function shall deallocate the storage referenced by the pointer, ending the duration of the region of storage.
Consider this example:
int main(){
auto p = operator new(sizeof(char)); // #0
operator delete(p); // #1
}
#1 is an invocation of a deallocation function, and it ends the duration of the region of storage referenced by p. However, according to [intro.races] note 7
An evaluation does not happen before itself.
So, p is not valid in #1, therefore, the program has UB?
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.compound] p5 says:
[basic.stc.dynamic.deallocation] p5 says:
Consider this example:
#1is an invocation of a deallocation function, and it ends the duration of the region of storage referenced byp. However, according to [intro.races] note 7So,
pis not valid in#1, therefore, the program has UB?