rust/src/libcore/num
Alex Crichton 5f39ceb729 std: Make abs() panic on overflow in debug mode
Debug overflow checks for arithmetic negation landed in #24500, at which time
the `abs` method on signed integers was changed to using `wrapping_neg` to
ensure that the function never panicked. This implied that `abs` of `INT_MIN`
would return `INT_MIN`, another negative value. When this change was back-ported
to beta, however, in #24708, the `wrapping_neg` function had not yet been
backported, so the implementation was changed in #24785 to `!self + 1`. This
change had the unintended side effect of enabling debug overflow checks for the
`abs` function. Consequently, the current state of affairs is that the beta
branch checks for overflow in debug mode for `abs` and the nightly branch does
not.

This commit alters the behavior of nightly to have `abs` always check for
overflow in debug mode. This change is more consistent with the way the standard
library treats overflow as well, and it is also not a breaking change as it's
what the beta branch currently does (albeit if by accident).

cc #25378
2015-05-18 17:51:23 -07:00
..
flt2dec core: use banker's rounding for the exact mode in flt2dec. 2015-05-06 21:11:14 +09:00
f32.rs std: Bring back f32::from_str_radix as an unstable API 2015-04-21 15:23:54 -07:00
f64.rs std: Bring back f32::from_str_radix as an unstable API 2015-04-21 15:23:54 -07:00
float_macros.rs std: Don't use a wrapper for the float error type 2015-05-01 16:44:36 -07:00
i8.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
i16.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
i32.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
i64.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
int_macros.rs Change the type of constants BYTES/BITS to usize 2015-03-30 12:19:11 +03:00
isize.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
mod.rs std: Make abs() panic on overflow in debug mode 2015-05-18 17:51:23 -07:00
u8.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
u16.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
u32.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
u64.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
uint_macros.rs Change the type of constants BYTES/BITS to usize 2015-03-30 12:19:11 +03:00
usize.rs Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
wrapping.rs Add missing inline attribute to Not impl for Wrapping<T> 2015-05-06 21:21:23 +02:00