#12798 closed Bugs (fixed)
Strange division evaluation for dynamically allocated `cpp_bin_float`
Reported by: | Michel Morin | Owned by: | John Maddock |
---|---|---|---|
Milestone: | Boost 1.64.0 | Component: | multiprecision |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
With this code
#include <iostream> #include <boost/multiprecision/cpp_bin_float.hpp> using namespace boost::multiprecision; using Real = number<cpp_bin_float<10000, digit_base_10, std::allocator<void>>>; int main(int argc, char* argv[]) { std::cout << 1 / Real(1.4) << std::endl; return 0; }
assertion fails as
Assertion failed: (( eval_msb(q) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 )), function eval_divide, file boost/multiprecision/cpp_bin_float.hpp, line 1086.
or it prints 26699.6
when compiled with NDEBUG
.
If I change Real(1.4)
to Real(1)
, the program does not terminate.
Tested on g++-5.4.
Change History (2)
comment:1 by , 6 years ago
Milestone: | To Be Determined → Boost 1.64.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:2 by , 6 years ago
Confirmed that the testcase works fine. Thanks for the quick fix!
Regards, Michel
Note:
See TracTickets
for help on using tickets.
I've tracked this down to a bug in cpp_int, fixed in: https://github.com/boostorg/multiprecision/commit/cd2bbcba5bc0f8335fd7d93bf1d8ffe875e722a0