From bc240ff606586bae4e1496ec3954c2f3a2b27c76 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Sep 2017 12:11:48 +0200 Subject: [PATCH] add an undef validation test --- tests/compile-fail/validation_undef.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/compile-fail/validation_undef.rs diff --git a/tests/compile-fail/validation_undef.rs b/tests/compile-fail/validation_undef.rs new file mode 100644 index 0000000000000..b889b1ea5317b --- /dev/null +++ b/tests/compile-fail/validation_undef.rs @@ -0,0 +1,14 @@ +#![allow(unused_variables)] +// error-pattern: attempted to read undefined bytes + +mod safe { + use std::mem; + + pub(crate) fn make_float() -> f32 { + unsafe { mem::uninitialized() } + } +} + +fn main() { + let _x = safe::make_float(); +}