1 // needed because negating int::MIN will behave differently between
2 // optimized compilation and unoptimized compilation and thus would
3 // lead to different lints being emitted
5 // revisions: noopt opt opt_with_overflow_checks
6 //[noopt]compile-flags: -C opt-level=0
7 //[opt]compile-flags: -O
8 //[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
12 #![feature(rustc_attrs)]
14 fn black_box<T>(_: T) {
20 //~^ ERROR arithmetic operation will overflow
21 let a_i128 = -i128::MIN;
22 //~^ ERROR arithmetic operation will overflow
23 let b = 200u8 + 200u8 + 200u8;
24 //~^ ERROR arithmetic operation will overflow
25 let b_i128 = i128::MIN - i128::MAX;
26 //~^ ERROR arithmetic operation will overflow
28 //~^ ERROR arithmetic operation will overflow
29 let d = 42u8 - (42u8 + 1);
30 //~^ ERROR arithmetic operation will overflow
32 //~^ ERROR operation will panic