Allow delete_array(nullptr) and delete_(nullptr)
From C++14 [expr.delete]:
In the first alternative (delete object), the value of the operand of delete may be a null pointer value, a pointer to a non-array object created by a previous new-expression, [...]. In the second alternative (delete array), the value of the operand of delete may be a null pointer value or a pointer value that resulted from a previous array new-expression.
However our current Preconditions for upcxx::delete_(g)
and upcxx::delete_array(g)
include:
g must be a non-deallocated pointer
We should expand this precondition to mirror the behavior of C++ delete, so that we accept delete_array(nullptr)
and delete_(nullptr)
and treat them as no-ops.
Comments (2)
-
reporter -
- changed status to resolved
Allow delete_() and delete_array() to be invoked on a null pointer. This fixes Issue
#114.→ <<cset 0d52695dba29>>
- Log in to comment
I've verified the implementation already contains the null checks to handle this correctly, although there are no tests for this functionality.