rust/tests/fail/intrinsics/float_to_int_32_nan.rs

11 lines
322 B
Rust
Raw Normal View History

#![feature(intrinsics)]
// Directly call intrinsic to avoid debug assertions in libstd
extern "rust-intrinsic" {
fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
}
fn main() {
unsafe { float_to_int_unchecked::<f32, u32>(f32::NAN); } //~ ERROR: cannot be represented in target type `u32`
}