blob: 62c77f76d9064ca7325cc14369ea7dc2b59ecb03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// build-pass
// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors)
// compile-flags: -C overflow-checks=on -O
#![warn(const_err)]
fn main() {
println!("{}", 0u32 - 1);
//~^ WARN attempt to subtract with overflow
let _x = 0u32 - 1;
//~^ WARN attempt to subtract with overflow
println!("{}", 1 / (1 - 1));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~| WARN erroneous constant used [const_err]
let _x = 1 / (1 - 1);
//~^ WARN const_err
println!("{}", 1 / (false as u32));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~| WARN erroneous constant used [const_err]
let _x = 1 / (false as u32);
//~^ WARN const_err
}
|