Rust code, including within unsafe
blocks and unsafe
functions is incorrect if it exhibits any of the behaviors in the following list. It is the programmer's responsibility when writing unsafe
code that it is not possible to let safe
code exhibit these behaviors.
read_unaligned
and write_unaligned
.&mut T
and &T
follow LLVM’s scoped noalias model, except if the &T
contains an UnsafeCell<U>
.let
binding), unless that data is contained within an UnsafeCell<U>
.offset
with the exception of one byte past the end of the object.std::ptr::copy_nonoverlapping_memory
, a.k.a. the memcpy32
and memcpy64
intrinsics, on overlapping buffers.false
(0
) or true
(1
) in a bool
.enum
not included in the type definition.char
which is a surrogate or above char::MAX
.str
.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/reference/behavior-considered-undefined.html