forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134073 - DianQK:fix-131227, r=oli-obk
dataflow_const_prop: do not eval a ptr address in SwitchInt Fixes rust-lang#131227.
- Loading branch information
Showing
3 changed files
with
26 additions
and
18 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 was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
tests/ui/dataflow_const_prop/ptr-in-switch-int-issue-131227.rs
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,19 @@ | ||
//! Issue: <https://github.com/rust-lang/rust/issues/131227> | ||
//! Test that constant propagation in SwitchInt does not crash | ||
//! when encountering a ptr-to-int transmute. | ||
//@ check-pass | ||
//@ compile-flags: -Zmir-enable-passes=+InstSimplify-before-inline,+DataflowConstProp | ||
|
||
#![crate_type = "lib"] | ||
|
||
static mut G: i32 = 0; | ||
|
||
pub fn myfunc() -> i32 { | ||
let var = &raw mut G; | ||
let u: usize = unsafe { std::mem::transmute(var) }; | ||
match u { | ||
0 => 0, | ||
_ => 1, | ||
} | ||
} |