Title
Support for relaxed pointer safety
Status
cd2
Section
_N4885_6.7.5.5.4 [basic.stc.dynamic.safety]
Submitter
Jens Maurer

Created on 2009-04-03.00:00:00 last changed 143 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

Change _N4885_6.7.5.5.4 [basic.stc.dynamic.safety] paragraph 4 as follows to define the terms “strict pointer safety” and “relaxed pointer safety,” which could then be used by the library clauses to achieve the desired effect:

An implementation may have relaxed pointer safety, in which case the validity of a pointer value does not depend on whether it is a safely-derived pointer value or not. Alternatively, an implementation may have strict pointer safety, in which case if If a pointer value that is not a safely-derived pointer value is dereferenced or deallocated, and the referenced complete object is of dynamic storage duration and has not previously been declared reachable (_N4885_.20.10.5 [util.dynamic.safety]), the behavior is undefined. [Note: 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 whether an implementation has relaxed or strict pointer safety.
Date: 2022-01-06.00:00:00

According to _N4885_.20.10.5 [util.dynamic.safety] paragraph 16, when std::get_pointer_safety() returns std::pointer_safety::relaxed,

pointers that are not safely derived will be treated the same as pointers that are safely derived for the duration of the program.

However, _N4885_6.7.5.5.4 [basic.stc.dynamic.safety] paragraph 4 says unconditionally that

If a pointer value that is not a safely-derived pointer value is dereferenced or deallocated, and the referenced complete object is of dynamic storage duration and has not previously been declared reachable (_N4885_.20.10.5 [util.dynamic.safety]), the behavior is undefined.

This is a contradiction: the library clause attempts to constrain undefined behavior, which by definition is unconstrained.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2664
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-11-08 00:00:00adminsetstatus: review -> ready
2009-08-03 00:00:00adminsetmessages: + msg2183
2009-08-03 00:00:00adminsetstatus: open -> review
2009-04-03 00:00:00admincreate