From Jason Turner

[basic.stc.dynamic.safety]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptqamvkid/{from.md → to.md} +19 -19
tmp/tmptqamvkid/{from.md → to.md} RENAMED
@@ -1,29 +1,31 @@
1
- #### Safely-derived pointers <a id="basic.stc.dynamic.safety">[[basic.stc.dynamic.safety]]</a>
2
 
3
  A *traceable pointer object* is
4
 
5
- - an object of an object pointer type ([[basic.compound]]), or
6
  - an object of an integral type that is at least as large as
7
  `std::intptr_t`, or
8
- - a sequence of elements in an array of narrow character type (
9
- [[basic.fundamental]]), where the size and alignment of the sequence
10
  match those of some object pointer type.
11
 
12
- A pointer value is a *safely-derived pointer* to a dynamic object only
13
- if it has an object pointer type and it is one of the following:
 
14
 
15
- - the value returned by a call to the C++standard library implementation
16
- of `::operator new(std::{}size_t)` or
17
- `::operator new(std::size_t, std::align_val_t)` ;[^15]
18
  - the result of taking the address of an object (or one of its
19
  subobjects) designated by an lvalue resulting from indirection through
20
  a safely-derived pointer value;
21
- - the result of well-defined pointer arithmetic ([[expr.add]]) using a
 
 
 
22
  safely-derived pointer value;
23
- - the result of a well-defined pointer conversion ([[conv.ptr]], 
24
- [[expr.cast]]) of a safely-derived pointer value;
25
  - the result of a `reinterpret_cast` of a safely-derived pointer value;
26
  - the result of a `reinterpret_cast` of an integer representation of a
27
  safely-derived pointer value;
28
  - the value of an object whose value was copied from a traceable pointer
29
  object, where at the time of the copy the source object contained a
@@ -49,17 +51,15 @@ An implementation may have *relaxed pointer safety*, in which case the
49
  validity of a pointer value does not depend on whether it is a
50
  safely-derived pointer value. Alternatively, an implementation may have
51
  *strict pointer safety*, in which case a pointer value referring to an
52
  object with dynamic storage duration that is not a safely-derived
53
  pointer value is an invalid pointer value unless the referenced complete
54
- object has previously been declared reachable (
55
- [[util.dynamic.safety]]).
56
 
57
- [*Note 1*: The effect of using an invalid pointer value (including
58
- passing it to a deallocation function) is undefined, see 
59
- [[basic.stc.dynamic.deallocation]]. This is true even if the
60
- unsafely-derived pointer value might compare equal to some
61
- safely-derived pointer value. — *end note*]
62
 
63
  It is *implementation-defined* whether an implementation has relaxed or
64
  strict pointer safety.
65
 
 
1
+ ##### Safely-derived pointers <a id="basic.stc.dynamic.safety">[[basic.stc.dynamic.safety]]</a>
2
 
3
  A *traceable pointer object* is
4
 
5
+ - an object of an object pointer type [[basic.compound]], or
6
  - an object of an integral type that is at least as large as
7
  `std::intptr_t`, or
8
+ - a sequence of elements in an array of narrow character type
9
+ [[basic.fundamental]], where the size and alignment of the sequence
10
  match those of some object pointer type.
11
 
12
+ A pointer value is a *safely-derived pointer* to an object with dynamic
13
+ storage duration only if the pointer value has an object pointer type
14
+ and is one of the following:
15
 
16
+ - the value returned by a call to the C++ standard library
17
+ implementation of `::operator new(std::{}size_t)` or
18
+ `::operator new(std::size_t, std::align_val_t)` ;[^16]
19
  - the result of taking the address of an object (or one of its
20
  subobjects) designated by an lvalue resulting from indirection through
21
  a safely-derived pointer value;
22
+ - the result of well-defined pointer arithmetic [[expr.add]] using a
23
+ safely-derived pointer value;
24
+ - the result of a well-defined pointer conversion ([[conv.ptr]],
25
+ [[expr.type.conv]], [[expr.static.cast]], [[expr.cast]]) of a
26
  safely-derived pointer value;
 
 
27
  - the result of a `reinterpret_cast` of a safely-derived pointer value;
28
  - the result of a `reinterpret_cast` of an integer representation of a
29
  safely-derived pointer value;
30
  - the value of an object whose value was copied from a traceable pointer
31
  object, where at the time of the copy the source object contained a
 
51
  validity of a pointer value does not depend on whether it is a
52
  safely-derived pointer value. Alternatively, an implementation may have
53
  *strict pointer safety*, in which case a pointer value referring to an
54
  object with dynamic storage duration that is not a safely-derived
55
  pointer value is an invalid pointer value unless the referenced complete
56
+ object has previously been declared reachable [[util.dynamic.safety]].
 
57
 
58
+ [*Note 6*: The effect of using an invalid pointer value (including
59
+ passing it to a deallocation function) is undefined, see  [[basic.stc]].
60
+ This is true even if the unsafely-derived pointer value might compare
61
+ equal to some safely-derived pointer value. *end note*]
 
62
 
63
  It is *implementation-defined* whether an implementation has relaxed or
64
  strict pointer safety.
65