]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / compiler / rustc_codegen_gcc / tests / run / int_overflow.rs
index 6477b83982804646fbb7bc9c597e9dcd8a09a3d4..ea2c5add962ae3d871cc0a1a298d9e7b8f54da98 100644 (file)
@@ -1,7 +1,7 @@
 // Compiler:
 //
 // Run-time:
-//   stdout: Panicking
+//   stdout: Success
 //   status: signal
 
 #![allow(unused_attributes)]
@@ -64,7 +64,9 @@ mod intrinsics {
 #[no_mangle]
 pub fn panic(_msg: &str) -> ! {
     unsafe {
-        libc::puts("Panicking\0" as *const str as *const u8);
+        // Panicking is expected iff overflow checking is enabled.
+        #[cfg(debug_assertions)]
+        libc::puts("Success\0" as *const str as *const u8);
         libc::fflush(libc::stdout);
         intrinsics::abort();
     }
@@ -124,6 +126,15 @@ impl Add for isize {
 #[start]
 fn main(mut argc: isize, _argv: *const *const u8) -> isize {
     let int = 9223372036854775807isize;
-    let int = int + argc;
+    let int = int + argc;  // overflow
+
+    // If overflow checking is disabled, we should reach here.
+    #[cfg(not(debug_assertions))]
+    unsafe {
+        libc::puts("Success\0" as *const str as *const u8);
+        libc::fflush(libc::stdout);
+        intrinsics::abort();
+    }
+
     int
 }