You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate errors for overflowing division / remainder #69020
error: attempt to divide with overflow
--> src/main.rs:6:13
|
6 | let _ = i32::MIN / -1;
| ^^^^^^^^^^^^^
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(const_err)]
| ^^^^^^^^^
error: this expression will panic at runtime
--> src/main.rs:6:13
|
6 | let _ = i32::MIN / -1;
| ^^^^^^^^^^^^^ attempt to divide with overflow
This is because !overflow_check is true in release mode but divison and remainder still get overflow checks.
(This test case already covers the problem, so a fix does not need a new test case, it just needs to adjust the existing test case to no longer expect two ERROR per line.)
Basically the same issue also leads to duplicate errors for Neg, though that requires associated consts to actually trigger:
use std::i32;pubtraitFoo{constN:i32;}impl<T:Foo>FooforVec<T>{constN:i32 = -i32::MIN + T::N;}
shows
error: attempt to negate with overflow
--> src/lib.rs:8:20
|
8 | const N: i32 = -i32::MIN + T::N;
| ^^^^^^^^^
|
= note: `#[deny(const_err)]` on by default
error: this expression will panic at runtime
--> src/lib.rs:8:20
|
8 | const N: i32 = -i32::MIN + T::N;
| ^^^^^^^^^ attempt to negate with overflow
Here, the cause is that even in release builds, const bodies use checked arithmetic. (The assoc const is needed because otherwise the const body just gets evaluated, not analyzed statically by const-prop.)
Activity
RalfJung commentedon Feb 10, 2020
Basically the same issue also leads to duplicate errors for
Neg, though that requires associated consts to actually trigger:shows
Here, the cause is that even in release builds,
constbodies use checked arithmetic. (The assoc const is needed because otherwise the const body just gets evaluated, not analyzed statically by const-prop.)Rollup merge of rust-lang#69185 - RalfJung:const-prop-lints, r=oli-obk
Extend rust-lang#69020 test to include reversed order.
Move rust-lang#69020 test to ui/associated-const + rebless.
Rollup merge of rust-lang#70696 - jumbatm:extend-issue-69020-test, r=…
Auto merge of rust-lang#70734 - Dylan-DPC:rollup-xmncatq, r=Dylan-DPC