From 9bc7b6f437ed041e4f7e52c1bf7e646e3c088ea5 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 9 Jul 2014 22:01:31 +0200 Subject: typeck: check casts from pointers to floats, closes #15445 --- src/test/compile-fail/typeck-cast-pointer-to-float.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/compile-fail/typeck-cast-pointer-to-float.rs (limited to 'src/test') 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 or the MIT license +// , 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` +} -- cgit 1.4.1-3-g733a5