File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
src/tools/miri/tests/pass Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -452,6 +452,11 @@ mod mut_ptr;
452452///
453453/// This is almost the same as calling [`ptr::read`] and discarding
454454/// the result, but has the following advantages:
455+ // FIXME: say something more useful than "almost the same"?
456+ // There are open questions here: `read` requires the value to be fully valid, e.g. if `T` is a
457+ // `bool` it must be 0 or 1, if it is a reference then it must be dereferenceable. `drop_in_place`
458+ // only requires that `*to_drop` be "valid for dropping" and we have not defined what that means. In
459+ // Miri it currently (May 2024) requires nothing at all for types without drop glue.
455460///
456461/// * It is *required* to use `drop_in_place` to drop unsized types like
457462/// trait objects, because they can't be read out onto the stack and
Original file line number Diff line number Diff line change 1+ // Miri currently doesn't require types without drop glue to be
2+ // valid when dropped. This test confirms that behavior.
3+ // This is not a stable guarantee!
4+
5+ use std:: ptr;
6+
7+ fn main ( ) {
8+ let mut not_a_bool = 13u8 ;
9+ unsafe {
10+ ptr:: drop_in_place ( & mut not_a_bool as * mut u8 as * mut bool )
11+ } ;
12+ }
You can’t perform that action at this time.
0 commit comments