Boost C++ Libraries: Ticket #12798: Strange division evaluation for dynamically allocated `cpp_bin_float` https://svn.boost.org/trac10/ticket/12798 <p> With this code </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/multiprecision/cpp_bin_float.hpp&gt; using namespace boost::multiprecision; using Real = number&lt;cpp_bin_float&lt;10000, digit_base_10, std::allocator&lt;void&gt;&gt;&gt;; int main(int argc, char* argv[]) { std::cout &lt;&lt; 1 / Real(1.4) &lt;&lt; std::endl; return 0; } </pre><p> assertion fails as </p> <pre class="wiki">Assertion failed: (( eval_msb(q) == cpp_bin_float&lt;Digits, DigitBase, Allocator, Exponent, MinE, MaxE&gt;::bit_count - 1 )), function eval_divide, file boost/multiprecision/cpp_bin_float.hpp, line 1086. </pre><p> or it prints <code>26699.6</code> when compiled with <code>NDEBUG</code>. If I change <code>Real(1.4)</code> to <code>Real(1)</code>, the program does not terminate. </p> <p> Tested on g++-5.4. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12798 Trac 1.4.3 John Maddock Fri, 03 Feb 2017 19:40:32 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/12798#comment:1 https://svn.boost.org/trac10/ticket/12798#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.64.0</span> </li> </ul> <p> I've tracked this down to a bug in cpp_int, fixed in: <a class="ext-link" href="https://github.com/boostorg/multiprecision/commit/cd2bbcba5bc0f8335fd7d93bf1d8ffe875e722a0"><span class="icon">​</span>https://github.com/boostorg/multiprecision/commit/cd2bbcba5bc0f8335fd7d93bf1d8ffe875e722a0</a> </p> Ticket Michel Morin Sat, 04 Feb 2017 08:14:50 GMT <link>https://svn.boost.org/trac10/ticket/12798#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12798#comment:2</guid> <description> <p> Confirmed that the testcase works fine. Thanks for the quick fix! </p> <p> Regards, Michel </p> </description> <category>Ticket</category> </item> </channel> </rss>