Boost C++ Libraries: Ticket #8711: cpp_int fails to construct correctly from minimum negative https://svn.boost.org/trac10/ticket/8711 <p> A cpp_int fails to construct correctly with the minimum negative value of a (platform dependent?) signed integral type. </p> <p> Example: </p> <pre class="wiki">template&lt;typename T, class I&gt; void test_boost_multiprecision() { T negMin = std::numeric_limits&lt;T&gt;::min(); I test1(negMin), test2( negMin + 1 ); --test2; assert( test1 == test2 ); // This fails on my platform for T = long assert( test1 != 0 ); assert( test1 == negMin ); assert( test2 != 0 ); assert( test2 == negMin ); // This fails on my platform for T = long } test_boost_multiprecision&lt;int64_t, boost::multiprecision::checked_cpp_int&gt;(); // Fails on my platform // The following hold for my platform: x86_64-apple-darwin12.4.0, // using: Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) // with: -std=c++11 -stdlib=libc++ // static_assert(std::numeric_limits&lt;long long&gt;::min() == std::numeric_limits&lt;int64_t&gt;::min(), "Ok"); // static_assert(std::numeric_limits&lt;long&gt;::min() == std::numeric_limits&lt;int64_t&gt;::min(), "Ok"); </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8711 Trac 1.4.3 Jan Bouwer <JBouwer@…> Wed, 19 Jun 2013 11:04:36 GMT attachment set https://svn.boost.org/trac10/ticket/8711 https://svn.boost.org/trac10/ticket/8711 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_multiprecision_error_demo.cpp</span> </li> </ul> <p> A demonstration of the error. </p> Ticket Jan Bouwer <JBouwer@…> Wed, 19 Jun 2013 11:07:48 GMT attachment set https://svn.boost.org/trac10/ticket/8711 https://svn.boost.org/trac10/ticket/8711 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_multiprecision_max_negative.patch</span> </li> </ul> <p> A naive patch suggestion. </p> Ticket John Maddock Fri, 21 Jun 2013 18:20:09 GMT status changed https://svn.boost.org/trac10/ticket/8711#comment:1 https://svn.boost.org/trac10/ticket/8711#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Confirmed, investigating. </p> Ticket John Maddock Mon, 24 Jun 2013 10:36:03 GMT <link>https://svn.boost.org/trac10/ticket/8711#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8711#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84897" title="Add some typecasts to ensure conversion from negative values proceeds ...">[84897]</a>) Add some typecasts to ensure conversion from negative values proceeds correctly. Fix masking of values during construction so overflow wraps around in unchecked fixed precision integers. Add tests for above changes. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8711" title="#8711: Bugs: cpp_int fails to construct correctly from minimum negative (closed: fixed)">#8711</a>. </p> </description> <category>Ticket</category> </item> <item> <author>Jan Bouwer <JBouwer@…></author> <pubDate>Sun, 30 Jun 2013 11:26:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8711#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8711#comment:3</guid> <description> <p> This indeed fixes the issue I experienced (and others along the same line). </p> <p> Thanks - your work (here and elsewhere) are much appreciated. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Mon, 09 Sep 2013 08:05:38 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/8711#comment:4 https://svn.boost.org/trac10/ticket/8711#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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.55.0</span> </li> </ul> Ticket