Title
Non-dereference use of invalid pointers
Status
cd3
Section
_N4885_6.7.5.5.4 [basic.stc.dynamic.safety]
Submitter
Anthony Williams

Created on 2012-01-03.00:00:00 last changed 130 months ago

Messages

Date: 2012-10-15.00:00:00

[Moved to DR at the October, 2012 meeting.]

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

Change 6.7.5.5.3 [basic.stc.dynamic.deallocation] paragraph 4 as follows:

If the argument given to a deallocation function in the standard library is a pointer that is not the null pointer value (7.3.12 [conv.ptr]), the deallocation function shall deallocate the storage referenced by the pointer, rendering invalid all pointers referring to any part of the deallocated storage. The effect of using an invalid pointer value (including passing it to a deallocation function) is undefined Indirection through an invalid pointer value and passing an invalid pointer value to a deallocation function have undefined behavior. Any other use of an invalid pointer value has implementation-defined behavior. [Footnote: On some Some implementations, it might define that copying an invalid pointer value causes a system-generated runtime fault. —end footnote]
Date: 2012-01-03.00:00:00

The current Standard says that any use of an invalid pointer value produces undefined behavior (6.7.5.5.3 [basic.stc.dynamic.deallocation] paragraph 4). This includes not only dereferencing the pointer but even just fetching its value. The reason for this draconian restriction is that some architectures in the past used dedicated address registers for pointer loads and stores and they could fault if, for example, a segment number in a pointer was not currently mapped.

It is not clear whether such restrictions are necessary with architectures currently in use or reasonably foreseen. This should be investigated to see if the restriction can be loosened to apply only to dereferencing the pointer.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: + msg4119
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: + msg3690
2012-02-27 00:00:00adminsetstatus: open -> ready
2012-01-03 00:00:00admincreate