Whether I use the inner or outer attribute, the following snippet panics with "attempt to add with overflow"
#[allow(arithmetic_overflow)]
fn main() {
// #![allow(arithmetic_overflow)]
let a: u32 = (1 << 31) + 322;
let _ = a + (1 << 31);
}
I don't want to use Wrapping
since I'm doing lots of arithmetic, it would be a real hassle.
(Playground )
#[allow(arithmetic_overflow)]
disables the arithmetic_overflow compile-time lint. It doesn't change the behavior of the arithmetic operations.
1 Like
@sfackler I don't understand. When I compile for release, overflow doesn't crash the app. When I compile for debug, overflow crashes the app. Can't I turn off that debug warning? Maybe some argument to pass to the compiler, like force-overflow-checks=no
?
tczajka
January 30, 2023, 11:58pm
4
You can disable overflow checks with a flag in Cargo.toml
:
[profile.dev]
overflow-checks = false
1 Like
Oh, I see, I was trying that in the package Cargo.toml
where it has no effect. I had to move it to the workspace Cargo.toml
.
system
Closed
May 1, 2023, 12:07am
6
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.