2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2021-12-03 15:32:51 +00:00
|
|
|
// needs-unwind
|
2017-02-17 21:00:08 +00:00
|
|
|
// compile-flags: -C overflow-checks
|
|
|
|
|
|
|
|
use std::panic;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 07:59:11 +00:00
|
|
|
[1, i32::MAX].iter().sum::<i32>();
|
2017-02-17 21:00:08 +00:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 07:59:11 +00:00
|
|
|
[2, i32::MAX].iter().product::<i32>();
|
2017-02-17 21:00:08 +00:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 07:59:11 +00:00
|
|
|
[1, i32::MAX].iter().cloned().sum::<i32>();
|
2017-02-17 21:00:08 +00:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 07:59:11 +00:00
|
|
|
[2, i32::MAX].iter().cloned().product::<i32>();
|
2017-02-17 21:00:08 +00:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
}
|