allow deref of null ptr in test
This commit is contained in:
parent
f76e256086
commit
648638976a
4 changed files with 4 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR inbounds test failed: 0x0 is not a valid pointer
|
||||
panic!("this should never print: {}", x);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Some optimizations remove ZST accesses, thus masking this UB.
|
||||
// compile-flags: -Zmir-opt-level=0
|
||||
|
||||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
let x: () = unsafe { *std::ptr::null() }; //~ ERROR memory access failed: 0x0 is not a valid pointer
|
||||
panic!("this should never print: {:?}", x);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
unsafe { *std::ptr::null_mut() = 0i32 }; //~ ERROR inbounds test failed: 0x0 is not a valid pointer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Some optimizations remove ZST accesses, thus masking this UB.
|
||||
// compile-flags: -Zmir-opt-level=0
|
||||
|
||||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
// Not using the () type here, as writes of that type do not even have MIR generated.
|
||||
// Also not assigning directly as that's array initialization, not assignment.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue