Skip to content

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

Closed
@xmh0511

Description

@xmh0511

[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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions