Title
Arguments to deallocation functions
Status
open
Section
7.6.2.9 [expr.delete]
Submitter
Matt Austern

Created on 2000-01-20.00:00:00 last changed 34 months ago

Messages

Date: 2022-02-18.07:47:23

Suggested resolution: A note should be added to 7.6.2.9 [expr.delete] to clarify that any offset added in an array new-expression must be subtracted in the array delete-expression.

Date: 2022-11-20.07:54:16

7.6.2.8 [expr.new] paragraph 10 says that the result of an array allocation function and the value of the array new-expression from which it was invoked may be different, allowing for space preceding the array to be used for implementation purposes such as saving the number of elements in the array. However, there is no corresponding description of the relationship between the operand of an array delete-expression and the argument passed to its deallocation function.

6.7.6.5.3 [basic.stc.dynamic.deallocation] paragraph 3 does state that

the value supplied to operator delete[](void*) in the standard library shall be one of the values returned by a previous invocation of either operator new[](std::size_t) or operator new[](std::size_t, const std::nothrow_t&) in the standard library.

This statement might be read as requiring an implementation, when processing an array delete-expression and calling the deallocation function, to perform the inverse of the calculation applied to the result of the allocation function to produce the value of the new-expression. (7.6.2.9 [expr.delete] paragraph 2 requires that the operand of an array delete-expression "be the pointer value which resulted from a previous array new-expression.") However, it is not completely clear whether the "shall" expresses an implementation requirement or a program requirement (or both). Furthermore, there is no direct statement about user-defined deallocation functions.

Suggested resolution: A note should be added to 7.6.2.9 [expr.delete] to clarify that any offset added in an array new-expression must be subtracted in the array delete-expression.

History
Date User Action Args
2022-02-18 07:47:23adminsetmessages: + msg6647
2000-01-20 00:00:00admincreate