Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
8152da82b51a16fbb7a072462af01d15b0b2c8d3
rust/tests/ui/mir/null/null_lhs.rs

11 lines
206 B
Rust
Raw Normal View History

Insert null checks for pointer dereferences when debug assertions are enabled Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2024-12-17 13:00:22 +00:00
//@ run-fail
//@ compile-flags: -C debug-assertions
occured -> occurred
2025-02-08 22:28:21 +00:00
//@ error-pattern: null pointer dereference occurred
Insert null checks for pointer dereferences when debug assertions are enabled Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2024-12-17 13:00:22 +00:00
fn main() {
let ptr: *mut u32 = std::ptr::null_mut();
unsafe {
*(ptr) = 42;
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 165ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API