File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,15 @@ support values.
111111
112112Safe code need not worry about ZSTs, but * unsafe* code must be careful about the
113113consequence 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 ] .
116115
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.
117120
121+ [ alloc ] : https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#tymethod.alloc
122+ [ ub ] : what-unsafe-does.html
118123
119124
120125
You can’t perform that action at this time.
0 commit comments