diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 08b4c37..b181ac6 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -879,6 +879,15 @@ namespace boost { { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); + + // GCC when used with flag -std=c++0x may not have std::numeric_limits + // specializations for __int128 and unsigned __int128 types. + // Try compilation with -std=gnu++0x or -std=gnu++11. + // + // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40856 + BOOST_STATIC_ASSERT_MSG(std::numeric_limits::is_specialized, + "std::numeric_limits are not specialized for integral type passed to boost::lexical_cast" + ); #endif CharT const czero = lcast_char_constants::zero; --end; diff --git a/test/lexical_cast_integral_types_test.cpp b/test/lexical_cast_integral_types_test.cpp index 1f43bac..8eb10c9 100644 --- a/test/lexical_cast_integral_types_test.cpp +++ b/test/lexical_cast_integral_types_test.cpp @@ -558,14 +558,33 @@ void test_conversion_from_to_ulonglong() #ifdef BOOST_LCAST_HAS_INT128 + +template +struct test_if_specialized { + static void test() {} +}; + +template +struct test_if_specialized { + static void test() { + test_conversion_from_to_integral_minimal(); + } +}; + void test_conversion_from_to_int128() { - test_conversion_from_to_integral_minimal(); + test_if_specialized< + std::numeric_limits::is_specialized, + boost::int128_type + >::test(); } void test_conversion_from_to_uint128() { - test_conversion_from_to_integral_minimal(); + test_if_specialized< + std::numeric_limits::is_specialized, + boost::uint128_type + >::test(); } #endif