about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_gcc/tests/run/int_overflow.rs')
-rw-r--r--compiler/rustc_codegen_gcc/tests/run/int_overflow.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs b/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
new file mode 100644
index 00000000000..78872159f62
--- /dev/null
+++ b/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
@@ -0,0 +1,23 @@
+// Compiler:
+//
+// Run-time:
+//   stdout: Success
+//   status: signal
+
+fn main() {
+    std::panic::set_hook(Box::new(|_| {
+        println!("Success");
+        std::process::abort();
+    }));
+
+    let arg_count = std::env::args().count();
+    let int = isize::MAX;
+    let _int = int + arg_count as isize;  // overflow
+
+    // If overflow checking is disabled, we should reach here.
+    #[cfg(not(debug_assertions))]
+    unsafe {
+        println!("Success");
+        std::process::abort();
+    }
+}