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(); +}