File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,15 @@ support values.
111
111
112
112
Safe code need not worry about ZSTs, but * unsafe* code must be careful about the
113
113
consequence of types with no size. In particular, pointer offsets are no-ops,
114
- and standard allocators may return ` null ` when a zero-sized allocation is
115
- requested, which is indistinguishable from the out of memory result.
114
+ and allocators typically [ require a non-zero size] [ alloc ] .
116
115
116
+ Note that references to ZSTs (including empty slices), just like all other
117
+ references, must be non-null and suitably aligned. Dereferencing a null or
118
+ unaligned pointer to a ZST is [ undefined behavior] [ ub ] , just like for any other
119
+ type.
117
120
121
+ [ alloc ] : https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#tymethod.alloc
122
+ [ ub ] : what-unsafe-does.html
118
123
119
124
120
125
You can’t perform that action at this time.
0 commit comments