-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #1904 - camelid:uninit-num, r=RalfJung
Add flag to check for uninitialized numbers Closes #1340. Companion rustc PR that implements this in the Miri engine: rust-lang/rust#88670 r? `@RalfJung`
- Loading branch information
Showing
11 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
db062de72b0a064f45b6f86894cbdc7c0ec68844 | ||
68ca579406f2fa9ec62710e4a4d5d3e07a168d3c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags: -Zmiri-check-number-validity | ||
|
||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312. | ||
|
||
fn main() { | ||
let _val = unsafe { std::mem::MaybeUninit::<f32>::uninit().assume_init() }; | ||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags: -Zmiri-check-number-validity | ||
|
||
// This test is from https://github.com/rust-lang/miri/issues/1340#issue-600900312. | ||
|
||
fn main() { | ||
let _val = unsafe { std::mem::MaybeUninit::<usize>::uninit().assume_init() }; | ||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags: -Zmiri-check-number-validity | ||
|
||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312. | ||
|
||
fn main() { | ||
let _val = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() }; | ||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
let _val = unsafe { std::mem::MaybeUninit::<*const u8>::uninit().assume_init() }; | ||
//~^ ERROR type validation failed at .value: encountered uninitialized raw pointer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312. | ||
// This test passes because -Zmiri-check-number-validity is not passed. | ||
|
||
fn main() { | ||
let _val1 = unsafe { std::mem::MaybeUninit::<usize>::uninit().assume_init() }; | ||
let _val2 = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() }; | ||
let _val3 = unsafe { std::mem::MaybeUninit::<f32>::uninit().assume_init() }; | ||
} |