Opened 9 years ago
Closed 9 years ago
#8711 closed Bugs (fixed)
cpp_int fails to construct correctly from minimum negative
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.55.0 | Component: | multiprecision |
Version: | Boost 1.53.0 | Severity: | Problem |
Keywords: | cpp_int negative minimum | Cc: |
Description
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");
Attachments (2)
Change History (6)
by , 9 years ago
Attachment: | boost_multiprecision_error_demo.cpp added |
---|
by , 9 years ago
Attachment: | boost_multiprecision_max_negative.patch added |
---|
A naive patch suggestion.
comment:2 by , 9 years ago
comment:3 by , 9 years ago
This indeed fixes the issue I experienced (and others along the same line).
Thanks - your work (here and elsewhere) are much appreciated.
comment:4 by , 9 years ago
Milestone: | To Be Determined → Boost 1.55.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
A demonstration of the error.