summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs
blob: 78872159f62da5dbc3714d7532ebb005ba53500f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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();
    }
}