Skip to content
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

"...denoted by the operand" in [expr.delete] can result in a wrong meaning #4746

Closed
xmh0511 opened this issue Jul 13, 2021 · 4 comments · Fixed by #4762
Closed

"...denoted by the operand" in [expr.delete] can result in a wrong meaning #4746

xmh0511 opened this issue Jul 13, 2021 · 4 comments · Fixed by #4762
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jul 13, 2021

[expr.delete#11]

For a single-object delete expression, the deleted object is the object denoted by the operand if its static type does not have a virtual destructor, and its most-derived object otherwise.

auto ptr = new int;
delete ptr;

The operand of the delete-expression is an unqualified-id ptr, the object denoted by the ptr is the object named ptr (rather than the object pointed by ptr), as per [expr.prim.id.unqual#3] and [basic#pre-5]

The result is the entity denoted by the unqualified-id ([basic.lookup.unqual]).

An entity E is denoted by the name (if any) that is introduced by a declaration of E or by a typedef-name introduced by a declaration specifying E.

The expected object in this sentence should be the object pointed by the operand. The original operand of a delete-expression could be of pointer type or class type, but, in either case, the ultimate operand shall have pointer type. So, I think in this sentence, change "the object denoted by the operand" to

the object pointed by the value of the operand.

might be a more precise utterance.

@jwakely
Copy link
Member

jwakely commented Jul 13, 2021

I think you mean pointed to, not just pointed.

And I don't think you need "the value of the operand". It's fine to say that a pointer points to something, we don't need to talk about the value of the pointer.

So "the object pointed to by the operand", or "the object the operand points to" seem OK to me.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jul 13, 2021

@jwakely Why I use the value of the operand has been discussed in #4662 (comment), we should explicitly specify the meaning. In addition, the value of the operand also implies lvalue-to-rvalue conversion may apply to the operand(if necessary).

@jwakely
Copy link
Member

jwakely commented Jul 13, 2021

I don't like adding extra words to "clarify" something that is not ambiguous. "The object pointed to by p" is obviously talking about the pointer value of p, not the type of p, because a type doesn't point to an object.

i.e. in cases like this, we already clearly differentiate between "pointer type" and "a value of pointer type".

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jul 13, 2021

It seems that the meaning of "the object pointed to by the operand" is clear. How about the lvalue-to-rvalue implied by "the value of..."? After all, the coversion is under-specified in many section in [expr] that should be specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants