New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[expr.delete] p7 The time of calling a deallocation function #4850
Comments
The storage for |
If you mean the new-expression at
The evaluation of an expression cannot be sequenced before that of itself. |
But it does produce a pointer value, which is deleted at |
However, the pointer value that is produced by a new-expression has another restriction, which is
As per [expr.new#14], |
True, [expr.new] p14 is not applicable for the new-expression that ends up calling the allocation function. However, the understanding is that the allocation function invoked by a new-expression does provide storage for that very new-expression (and possibly for others, as discussed in p14). |
Yes, however, it's impossible that the new-expresion that has been extended provides the storage for itself as per [expr.new#14.1], except that we say
|
We can certainly say in [expr.new] p10 "A new-expression may obtain storage for the object by calling an allocation function (6.7.5.5.2); the allocation is said to provide storage for the new-expression." There are simply several options how to provide storage for a new-expression; one is by calling "operator new" and another is by extending an allocation per the p14 rules. However, I'm hesitant to editorially extend the use of "provides storage" here some more, because [intro.object] p3 uses "provides storage" for a slightly different purpose. |
Since [expr.new] p15 says
Hence, to be consistent, [expr.delete] p7 should use the precise utterance
Not the extended new-expression provides the storage for a new-expression, instead, the allocation of the extended new-expression provides that storage. With the fix: A new-expression may obtain storage for the object by calling an allocation function (6.7.5.5.2); the allocation is said to provide storage for the new-expression. This issue will be ok. |
Consider this example
Assume the new-expression at
#0
has been extended to provide the storage for#1
and#2
. Note the emphasized wording in the second bullet, since there are only twonew-expression
that use the allocation provided by#0
, hence at this point at#4
, could we say the delete-expression for every other pointer value(...) has been evaluated? So, the deallocation function shall be called at#4
? At the point of#5
, the second bullet is also satisfied, hence it again call the deallocation function? Obviously, it does not make sense however it is what the second bullet saying.I think the second bullet is intend to cover the following case
This example is based on the first by adjusting the order of the delete-expression whose operand is produced by the extended allocation. The second bullet can work fine in this example, since
#4
has not been evaluated, hence#5
cannot invoke the deallocation function, it's the responsibility of#4
. However, as aforementioned, the second bullet seems not good at the first example.The text was updated successfully, but these errors were encountered: