// Compiler:
//
// Run-time:
-// stdout: Panicking
+// stdout: Success
// status: signal
#![allow(unused_attributes)]
#[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();
}
#[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
}