Skip to content

Commit 9e2eb8d

Browse files
authored
Rollup merge of rust-lang#136601 - compiler-errors:borrow-null-zst, r=saethlin
Detect (non-raw) borrows of null ZST pointers in CheckNull Fixes rust-lang#136568. Ensures that we check that borrows of derefs are non-null in the `CheckNull` pass **even if** it's a ZST pointee. I'm actually surprised that this is UB in Miri, but if it's certainly UB, then this PR modifies the null check to be stricter. I couldn't find anywhere in https://doc.rust-lang.org/reference/behavior-considered-undefined.html that discusses this case specifically, but I didn't read it too closely, or perhaps it's just missing a bullet point. On the contrary, if this is actually erroneous UB in Miri, then I'm happy to close this (and perhaps fix the null check in Miri to exclude ZSTs?) On the double contrary, if this is still an "open question", I'm also happy to close this and wait for a decision to be made. r? ``@saethlin`` cc ``@RalfJung`` (perhaps you feel strongly about this change)
2 parents de555d8 + 275be80 commit 9e2eb8d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: core/src/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ fn panic_null_pointer_dereference() -> ! {
302302
}
303303

304304
panic_nounwind_fmt(
305-
format_args!("null pointer dereference occured"),
305+
format_args!("null pointer dereference occurred"),
306306
/* force_no_backtrace */ false,
307307
)
308308
}

0 commit comments

Comments
 (0)