From Jason Turner

[basic.stc.dynamic.safety]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpge6acg3l/{from.md → to.md} +0 -65
tmp/tmpge6acg3l/{from.md → to.md} RENAMED
@@ -1,65 +0,0 @@
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
32
- copy of a safely-derived pointer value.
33
-
34
- An integer value is an *integer representation of a safely-derived
35
- pointer* only if its type is at least as large as `std::intptr_t` and it
36
- is one of the following:
37
-
38
- - the result of a `reinterpret_cast` of a safely-derived pointer value;
39
- - the result of a valid conversion of an integer representation of a
40
- safely-derived pointer value;
41
- - the value of an object whose value was copied from a traceable pointer
42
- object, where at the time of the copy the source object contained an
43
- integer representation of a safely-derived pointer value;
44
- - the result of an additive or bitwise operation, one of whose operands
45
- is an integer representation of a safely-derived pointer value `P`, if
46
- that result converted by `reinterpret_cast<void*>` would compare equal
47
- to a safely-derived pointer computable from
48
- `reinterpret_cast<void*>(P)`.
49
-
50
- An implementation may have *relaxed pointer safety*, in which case the
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
-