From Jason Turner

[util.dynamic.safety]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpu7tzulft/{from.md → to.md} +0 -90
tmp/tmpu7tzulft/{from.md → to.md} RENAMED
@@ -1,90 +0,0 @@
1
- ### Pointer safety <a id="util.dynamic.safety">[[util.dynamic.safety]]</a>
2
-
3
- A complete object is *declared reachable* while the number of calls to
4
- `declare_reachable` with an argument referencing the object exceeds the
5
- number of calls to `undeclare_reachable` with an argument referencing
6
- the object.
7
-
8
- ``` cpp
9
- void declare_reachable(void* p);
10
- ```
11
-
12
- *Preconditions:* `p` is a safely-derived
13
- pointer [[basic.stc.dynamic.safety]] or a null pointer value.
14
-
15
- *Effects:* If `p` is not null, the complete object referenced by `p` is
16
- subsequently declared reachable [[basic.stc.dynamic.safety]].
17
-
18
- *Throws:* May throw `bad_alloc` if the system cannot allocate additional
19
- memory that may be required to track objects declared reachable.
20
-
21
- ``` cpp
22
- template<class T> T* undeclare_reachable(T* p);
23
- ```
24
-
25
- *Preconditions:* If `p` is not null, the complete object referenced by
26
- `p` has been previously declared reachable, and is live [[basic.life]]
27
- from the time of the call until the last `undeclare_reachable(p)` call
28
- on the object.
29
-
30
- *Returns:* A safely derived copy of `p` which compares equal to `p`.
31
-
32
- *Throws:* Nothing.
33
-
34
- [*Note 1*: It is expected that calls to `declare_reachable(p)` will
35
- consume a small amount of memory in addition to that occupied by the
36
- referenced object until the matching call to `undeclare_reachable(p)` is
37
- encountered. Long running programs should arrange that calls are
38
- matched. — *end note*]
39
-
40
- ``` cpp
41
- void declare_no_pointers(char* p, size_t n);
42
- ```
43
-
44
- *Preconditions:* No bytes in the specified range are currently
45
- registered with `declare_no_pointers()`. If the specified range is in an
46
- allocated object, then it is entirely within a single allocated object.
47
- The object is live until the corresponding `undeclare_no_pointers()`
48
- call.
49
-
50
- [*Note 2*: In a garbage-collecting implementation, the fact that a
51
- region in an object is registered with `declare_no_pointers()` should
52
- not prevent the object from being collected. — *end note*]
53
-
54
- *Effects:* The `n` bytes starting at `p` no longer contain traceable
55
- pointer locations, independent of their type. Hence indirection through
56
- a pointer located there is undefined if the object it points to was
57
- created by global `operator new` and not previously declared reachable.
58
-
59
- [*Note 3*: This may be used to inform a garbage collector or leak
60
- detector that this region of memory need not be traced. — *end note*]
61
-
62
- *Throws:* Nothing.
63
-
64
- [*Note 4*: Under some conditions implementations may need to allocate
65
- memory. However, the request can be ignored if memory allocation
66
- fails. — *end note*]
67
-
68
- ``` cpp
69
- void undeclare_no_pointers(char* p, size_t n);
70
- ```
71
-
72
- *Preconditions:* The same range has previously been passed to
73
- `declare_no_pointers()`.
74
-
75
- *Effects:* Unregisters a range registered with `declare_no_pointers()`
76
- for destruction. It shall be called before the lifetime of the object
77
- ends.
78
-
79
- *Throws:* Nothing.
80
-
81
- ``` cpp
82
- pointer_safety get_pointer_safety() noexcept;
83
- ```
84
-
85
- *Returns:* `pointer_safety::strict` if the implementation has strict
86
- pointer safety [[basic.stc.dynamic.safety]]. It is
87
- *implementation-defined* whether `get_pointer_safety` returns
88
- `pointer_safety::relaxed` or `pointer_safety::preferred` if the
89
- implementation has relaxed pointer safety.[^1]
90
-