// these errors are not actually "const_err", they occur in trans/consts
// and are unconditional warnings that can't be denied or allowed
-#![feature(rustc_attrs)]
#![allow(exceeding_bitshifts)]
#![allow(const_err)]
//~^ ERROR array index out of bounds
//~^^ ERROR array index out of bounds
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let a = -std::i8::MIN;
//~^ WARN attempted to negate with overflow
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(rustc_attrs)]
#![allow(unused_imports)]
// Note: the relevant lint pass here runs before some of the constant
//~^ ERROR attempted to multiply with overflow
);
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
foo(VALS_I8);
foo(VALS_I16);
// error-pattern:attempted to divide by zero
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let y = 0;
let _z = 1 / y;
// error-pattern:attempted remainder with a divisor of zero
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let y = 0;
let _z = 1 % y;
// compile-flags: -C debug-assertions
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = 200u8 + 200u8 + 200u8;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = 1_i32 << 32;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = 1 << -1;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = 1_u64 << 64;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
// this signals overflow when checking is on
let x = 1_i8 << 17;
// error-pattern:thread 'main' panicked at 'arithmetic operation overflowed'
// compile-flags: -C debug-assertions
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let x = 200u8 * 4;
}
// error-pattern:thread 'main' panicked at 'attempted to negate with overflow'
// compile-flags: -C debug-assertions
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = -std::i8::MIN;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = -1_i32 >> 32;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = -1_i32 >> -1;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = -1_i64 >> 64;
}
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
// this signals overflow when checking is on
let x = 2_i8 >> 17;
#![warn(exceeding_bitshifts)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _n = 1i64 >> [64][0];
}
#![warn(exceeding_bitshifts)]
#![feature(const_indexing)]
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _n = 1i64 >> [64][0];
}
// error-pattern:thread 'main' panicked at 'arithmetic operation overflowed'
// compile-flags: -C debug-assertions
-#![feature(rustc_attrs)]
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
let _x = 42u8 - (42u8 + 1);
}
}
fn overflow() {
- #[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn add(a: u8, b: u8) -> u8 { a + b }
add(200u8, 200u8);
macro_rules! check {
($($e:expr),*) => {
$(assert!(thread::spawn({
- #[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
move|| { $e; }
}).join().is_err());)*
}
}
-#[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
fn main() {
check![
isize::min_value() / -1,