[Boost-bugs] [Boost C++ Libraries] #8711: cpp_int fails to construct correctly from minimum negative

Subject: [Boost-bugs] [Boost C++ Libraries] #8711: cpp_int fails to construct correctly from minimum negative
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-06-19 11:02:46


#8711: cpp_int fails to construct correctly from minimum negative
--------------------------------------+----------------------------
 Reporter: Jan Bouwer <JBouwer@…> | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: cpp_int negative minimum |
--------------------------------------+----------------------------
 A cpp_int fails to construct correctly with the minimum negative value of
 a (platform dependent?) signed integral type.

 Example:
 {{{
 template<typename T, class I>
 void test_boost_multiprecision()
 {
     T negMin = std::numeric_limits<T>::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<int64_t,
 boost::multiprecision::checked_cpp_int>(); // 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<long long>::min() ==
 std::numeric_limits<int64_t>::min(), "Ok");
 // static_assert(std::numeric_limits<long>::min() ==
 std::numeric_limits<int64_t>::min(), "Ok");
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8711>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC