Title
Deleting a null function pointer
Status
cd2
Section
7.6.2.9 [expr.delete]
Submitter
Martin Sebor

Created on 2006-10-03.00:00:00 last changed 170 months ago

Messages

Date: 2009-07-15.00:00:00

[Voted into WP at July, 2009 meeting.]

Date: 2008-09-15.00:00:00

Proposed resolution (September, 2008):

  1. Change 7.6.2.9 [expr.delete] paragraph 1 as follows:

  2. ...The operand shall have a pointer to object type, or a class type having a single non-explicit conversion function (12.3.2) to a pointer to object type. [Footnote: This implies that an object cannot be deleted using a pointer of type void* because void is not an object type. —end footnote] ...
  3. Delete the footnote at the end of 7.6.2.9 [expr.delete] paragraph 3:

  4. ...if the dynamic type of the object to be deleted differs from its static type, the behavior is undefined. [Footnote: This implies that an object cannot be deleted using a pointer of type void* because there are no objects of type void. —end footnote]
Date: 2008-06-15.00:00:00

Proposed resolution (June, 2008):

Change 7.6.2.9 [expr.delete] paragraph 1 as follows:

...The operand shall have a pointer to object type, or a class type having a single non-explicit conversion function (11.4.8.3 [class.conv.fct]) to a pointer to object type...
Date: 2022-02-18.07:47:23

The requirements for the operand of the delete operators are given in 7.6.2.9 [expr.delete] paragraph 2:

In either alternative, the value of the operand of delete may be a null pointer value. If it is not a null pointer value, in the first alternative (delete object), the value of the operand of delete shall be a pointer to a non-array object or a pointer to a subobject (6.7.2 [intro.object]) representing a base class of such an object (11.7 [class.derived]). If not, the behavior is undefined. In the second alternative (delete array), the value of the operand of delete shall be the pointer value which resulted from a previous array new-expression. If not, the behavior is undefined.

There are no restrictions on the type of a null pointer, only on a pointer that is not null. That seems wrong.

History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-11-08 00:00:00adminsetstatus: dr -> wp
2009-08-03 00:00:00adminsetmessages: + msg2254
2009-08-03 00:00:00adminsetstatus: ready -> dr
2009-03-23 00:00:00adminsetstatus: review -> ready
2008-10-05 00:00:00adminsetmessages: + msg1765
2008-06-29 00:00:00adminsetmessages: + msg1698
2008-06-29 00:00:00adminsetstatus: drafting -> review
2007-05-06 00:00:00adminsetstatus: open -> drafting
2006-10-03 00:00:00admincreate