diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 66e5370..08b4c37 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -69,11 +69,11 @@ throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))) #endif -#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700 +// GCC 4.6 has some issues with int128 and uint128. Issues were fixed in GCC 4.7 +#if defined(BOOST_HAS_INT128) && (!defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)) #define BOOST_LCAST_HAS_INT128 #endif - namespace boost { // exception used to indicate runtime lexical_cast failure diff --git a/test/lexical_cast_integral_types_test.cpp b/test/lexical_cast_integral_types_test.cpp index 235287e..1f43bac 100644 --- a/test/lexical_cast_integral_types_test.cpp +++ b/test/lexical_cast_integral_types_test.cpp @@ -48,7 +48,7 @@ #define BOOST_LCAST_NO_WCHAR_T #endif -#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700 +#if defined(BOOST_HAS_INT128) && (!defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)) #define BOOST_LCAST_HAS_INT128 #endif @@ -444,8 +444,8 @@ void test_conversion_from_to_integral_minimal() // test_conversion_from_to_integral_for_locale // Overflow test case from David W. Birdsall - std::string must_owerflow_str = "160000000000000000000"; - std::string must_owerflow_negative_str = "-160000000000000000000"; + std::string must_owerflow_str = (sizeof(T) < 16 ? "160000000000000000000" : "1600000000000000000000000000000000000000"); + std::string must_owerflow_negative_str = (sizeof(T) < 16 ? "-160000000000000000000" : "-1600000000000000000000000000000000000000"); for (int i = 0; i < 15; ++i) { BOOST_CHECK_THROW(lexical_cast(must_owerflow_str), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(must_owerflow_negative_str), bad_lexical_cast);