]> git.lizzy.rs Git - rust.git/commitdiff
add an undef validation test
authorRalf Jung <post@ralfj.de>
Sat, 16 Sep 2017 10:11:48 +0000 (12:11 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 16 Sep 2017 10:11:48 +0000 (12:11 +0200)
tests/compile-fail/validation_undef.rs [new file with mode: 0644]

diff --git a/tests/compile-fail/validation_undef.rs b/tests/compile-fail/validation_undef.rs
new file mode 100644 (file)
index 0000000..b889b1e
--- /dev/null
@@ -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();
+}