rustc: implement arithmetic overflow checking
Adds overflow checking to integer addition, multiplication, and subtraction when `-Z force-overflow-checks` is true, or if `--cfg ndebug` is not passed to the compiler. On overflow, it panics with `arithmetic operation overflowed`. Also adds `overflowing_add`, `overflowing_sub`, and `overflowing_mul` intrinsics for doing unchecked arithmetic. [breaking-change]
This commit is contained in:
parent
00ccc7af1e
commit
cdfff9db35
10 changed files with 203 additions and 7 deletions
|
|
@ -259,7 +259,6 @@ pub enum CrateType {
|
|||
CrateTypeStaticlib,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Passes {
|
||||
SomePasses(Vec<String>),
|
||||
|
|
@ -585,6 +584,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
"Adds unstable command line options to rustc interface"),
|
||||
print_enum_sizes: bool = (false, parse_bool,
|
||||
"Print the size of enums and their variants"),
|
||||
force_overflow_checks: Option<bool> = (None, parse_opt_bool,
|
||||
"Force overflow checks on or off"),
|
||||
}
|
||||
|
||||
pub fn default_lib_output() -> CrateType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue