deleting a pointer when the static type and dynamic types are similar is potentially UB CWG2474 #4305
Labels
cwg
Issue must be reviewed by CWG.
not-editorial
Issue is not deemed editorial; the editorial issue is kept open for tracking.
http://eel.is/c++draft/expr.delete#3
"static type" and "dynamic type" includes cv qualification. By the standard wording invoking
foo
andbar
is undefined behavior in the following code:Proposed changes:
In a single-object delete expression, if the static type of the object to be deleted is
different fromnot similar to its dynamic type and the selected deallocation function (see below) is not a destroying operator delete, the static type shall be a base class of the dynamic type of the object to be deleted and the static type shall have a virtual destructor or the behavior is undefined.In an array delete expression, if the dynamic type of the object to be deleted
differs fromis not similar to its static type, the behavior is undefined.The text was updated successfully, but these errors were encountered: