about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2014-07-09 22:01:31 +0200
committerFlorian Hahn <flo@fhahn.com>2014-07-10 12:28:46 +0200
commit9bc7b6f437ed041e4f7e52c1bf7e646e3c088ea5 (patch)
tree4472a529b18e5edd51c8fc19cbd09b2c51ec21fd /src/test
parent6372915a78a12adfbc327aba87225988ae03e7f9 (diff)
downloadrust-9bc7b6f437ed041e4f7e52c1bf7e646e3c088ea5.tar.gz
rust-9bc7b6f437ed041e4f7e52c1bf7e646e3c088ea5.zip
typeck: check casts from pointers to floats, closes #15445
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/typeck-cast-pointer-to-float.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/compile-fail/typeck-cast-pointer-to-float.rs b/src/test/compile-fail/typeck-cast-pointer-to-float.rs
new file mode 100644
index 00000000000..22a0978ef7c
--- /dev/null
+++ b/src/test/compile-fail/typeck-cast-pointer-to-float.rs
@@ -0,0 +1,15 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x : i16 = 22;
+    ((&x) as *const i16) as f32;
+    //~^ ERROR: cannot cast from pointer to float directly: `*const i16` as `f32`
+}