From 2e70fcdca8d8a7a8f584944d9320bee3a76c7bc2 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Tue, 13 Sep 2016 20:17:52 -0600 Subject: [PATCH] Undo accidental test deletion in previous commit. --- tests/compile-fail/static_memory_modification.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/compile-fail/static_memory_modification.rs diff --git a/tests/compile-fail/static_memory_modification.rs b/tests/compile-fail/static_memory_modification.rs new file mode 100644 index 000000000000..11961becb246 --- /dev/null +++ b/tests/compile-fail/static_memory_modification.rs @@ -0,0 +1,9 @@ +static X: usize = 5; + +#[allow(mutable_transmutes)] +fn main() { + unsafe { + *std::mem::transmute::<&usize, &mut usize>(&X) = 6; //~ ERROR: tried to modify constant memory + assert_eq!(X, 6); + } +}