This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


1190. Operations on non-safely-derived pointers

Section: _N4885_6.7.5.5.4  [basic.stc.dynamic.safety]     Status: C++11     Submitter: Hans Boehm     Date: 2010-09-01

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

_N4885_6.7.5.5.4 [basic.stc.dynamic.safety] paragraph 4 only prohibits the dereferencing and deallocation of non-safely-derived pointers. This is insufficient. Explicit deallocation of storage is described as rendering invalid all pointers to that storage, with the result that all operations on such a pointer value causes undefined behavior (6.7.5.5.3 [basic.stc.dynamic.deallocation] paragraph 4). The same should be true if the storage pointed to by a non-safely-derived pointer is garbage collected. In particular, the promise of objects having distinct addresses (6.7.2 [intro.object] paragraph 6) should not apply if one of those objects is designated by a non-safely-derived pointer.

Proposed resolution (November, 2010) [SUPERSEDED]:

Change _N4885_6.7.5.5.4 [basic.stc.dynamic.safety] paragraph 4 as follows:

...Alternatively, an implementation may have strict pointer safety, in which case, if a pointer value that is not a safely-derived pointer value is dereferenced or deallocated, and an invalid pointer value, unless the referenced complete object is of dynamic storage duration and has not previously been declared reachable (_N4700_.23.11.2 [util.smartptr]), the behavior is undefined. [Note: this The effect of using an invalid pointer value (including passing it to a deallocation function) is undefined, see 6.7.5.5.3 [basic.stc.dynamic.deallocation]. This is true even if the unsafely-derived pointer value might compare equal to some safely-derived pointer value. —end note] It is implementation defined...