]> git.lizzy.rs Git - rust.git/commitdiff
add test for simd division overflow UB
authorRalf Jung <post@ralfj.de>
Thu, 3 Mar 2022 17:32:42 +0000 (12:32 -0500)
committerRalf Jung <post@ralfj.de>
Thu, 3 Mar 2022 17:32:42 +0000 (12:32 -0500)
tests/compile-fail/intrinsics/simd-div-overflow.rs [new file with mode: 0644]

diff --git a/tests/compile-fail/intrinsics/simd-div-overflow.rs b/tests/compile-fail/intrinsics/simd-div-overflow.rs
new file mode 100644 (file)
index 0000000..277b9e8
--- /dev/null
@@ -0,0 +1,15 @@
+#![feature(platform_intrinsics, repr_simd)]
+
+extern "platform-intrinsic" {
+    pub(crate) fn simd_div<T>(x: T, y: T) -> T;
+}
+
+#[repr(simd)]
+#[allow(non_camel_case_types)]
+struct i32x2(i32, i32);
+
+fn main() { unsafe {
+    let x = i32x2(1, i32::MIN);
+    let y = i32x2(1, -1);
+    simd_div(x, y); //~ERROR Undefined Behavior: overflow in signed division
+} }