Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#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 John Maddock, 6 years ago

Milestone: To Be DeterminedBoost 1.64.0
Resolution: fixed
Status: newclosed

comment:2 by Michel Morin, 6 years ago

Confirmed that the testcase works fine. Thanks for the quick fix!

Regards, Michel

Note: See TracTickets for help on using tickets.