Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'attempt to negate with overflow' with specific values #20

Closed
Eijebong opened this issue Jul 28, 2019 · 3 comments
Closed

'attempt to negate with overflow' with specific values #20

Eijebong opened this issue Jul 28, 2019 · 3 comments

Comments

@Eijebong
Copy link

I updated float-cmp in librsvg and ran into this in the test suite. This only happens in debug mode.

fn main() {
    use float_cmp::ApproxEq;
    // -25.0 / 25.0 / 0.00390625
    println!("{:?}", (-25.0f64).approx_eq(25.0, (0.00390625, 1)));
}
thread 'main' panicked at 'attempt to negate with overflow', /builddir/build/BUILD/rustc-1.36.0-src/src/libcore/num/mod.rs:1972:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic
   9: core::num::<impl i64>::abs
             at /builddir/build/BUILD/rustc-1.36.0-src/src/libcore/num/mod.rs:1972
  10: <f64 as float_cmp::eq::ApproxEq>::approx_eq
             at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/float-cmp-0.5.1/src/eq.rs:230
  11: bug_fl::main
             at src/main.rs:4
  12: std::rt::lang_start::{{closure}}
             at /builddir/build/BUILD/rustc-1.36.0-src/src/libstd/rt.rs:64
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
  15: std::rt::lang_start_internal
  16: std::rt::lang_start
             at /builddir/build/BUILD/rustc-1.36.0-src/src/libstd/rt.rs:64
  17: main
  18: __libc_start_main
  19: _start
@mikedilger
Copy link
Owner

Nice catch of an edge case. I'll work out a fix shortly.

@mikedilger
Copy link
Owner

Solved nicely with rust-lang/rust#59983 but that is still on nightly.

@mikedilger
Copy link
Owner

Fixed in 0.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants