Closed
Description
While working on rebasing #20795 I discovered that the new run-fail
tests it adds were failing to panic, because the arithmetic in question was being handled by the constant evaluation, and the overflow was thus happening at compile time rather than run time.
An example of such an expression:
fn main() {
let x = 200u8 + 200u8 + 200u8;
}
(Thank goodness it didn't cause my rustc
to panic! That would have been a bit frustrating.)
Anyway, we should fix that, as part of #22020.
That is, the program above should fail to compile, and it should not cause an ICE; it should signal a proper error message saying that the arithmetic expression overflowed (because 200+200+200 == 600 > 255 == u8::MAX).