

Add support for `cfg(overflow_checks)` by AngelicosPhosphoros · Pull Request #11...
source link: https://github.com/rust-lang/rust/pull/111096
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Conversation
Contributor
This PR adds support for detecting if overflow checks are enabled in similar fashion as debug_assertions
are detected. Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g.
pub fn cast(val: usize)->u16 {
if cfg!(overflow_checks) {
val.try_into().unwrap()
}
else{
vas as _
}
}
Resolves #91130.
Recommend
-
7
ASM changes Codegen difference for code: #[repr(u32)] #[derive(Copy, Clone, Eq, PartialEq, PartialOrd)] pub enum Foo { Zero, One, Two, } pub fn compare(a: Foo, b: Foo)->bool{ a <= b }
-
5
Copy link Contributor Author Ange...
-
6
This is basically same commit as e38e954 which was reverted later i...
-
10
Conversation Copy link Contributor ...
-
10
Stamping Out Overflow Checks in Ruby Chris Seaton, 26 September 2021 Someone on Reddit
-
3
Copy link Contributor timoschilling com...
-
8
New issue Add try_reserve and try_reserve_exact for OsString #92338
-
13
Copy link FlixCoder commented...
-
7
Copy link Member
-
11
New issue adjust for div/rem overflow being UB #1992
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK