Index: boost/lexical_cast.hpp =================================================================== --- boost/lexical_cast.hpp (revision 84183) +++ boost/lexical_cast.hpp (revision 85160) @@ -69,9 +69,4 @@ throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))) #endif - -#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700 -#define BOOST_LCAST_HAS_INT128 -#endif - namespace boost @@ -317,5 +312,5 @@ #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 template <> struct stream_char_common< boost::int128_type >: public boost::mpl::identity< char > {}; template <> struct stream_char_common< boost::uint128_type >: public boost::mpl::identity< char > {}; @@ -614,5 +609,5 @@ BOOST_LCAST_DEF( __int64) #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 BOOST_LCAST_DEF(boost::int128_type) BOOST_LCAST_DEF(boost::uint128_type) @@ -880,4 +875,13 @@ #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; @@ -1828,5 +1832,5 @@ #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 bool operator<<(const boost::uint128_type& n) { start = lcast_put_unsigned(n, finish); return true; } bool operator<<(const boost::int128_type& n) { return shl_signed(n); } @@ -2040,5 +2044,5 @@ #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 bool operator>>(boost::uint128_type& output) { return shr_unsigned(output); } bool operator>>(boost::int128_type& output) { return shr_signed(output); } @@ -2554,5 +2558,5 @@ } #endif -#ifndef BOOST_NO_CHAR16_T +#ifndef BOOST_NO_CXX11_CHAR16_T template inline Target lexical_cast(const char16_t* chars, std::size_t count) @@ -2563,5 +2567,5 @@ } #endif -#ifndef BOOST_NO_CHAR32_T +#ifndef BOOST_NO_CXX11_CHAR32_T template inline Target lexical_cast(const char32_t* chars, std::size_t count) @@ -2720,5 +2724,4 @@ #undef BOOST_LCAST_THROW_BAD_CAST #undef BOOST_LCAST_NO_WCHAR_T -#undef BOOST_LCAST_HAS_INT128 #endif // BOOST_LEXICAL_CAST_INCLUDED Index: libs/conversion/test/lexical_cast_integral_types_test.cpp =================================================================== --- libs/conversion/test/lexical_cast_integral_types_test.cpp (revision 83764) +++ libs/conversion/test/lexical_cast_integral_types_test.cpp (revision 85160) @@ -49,8 +49,4 @@ #endif -#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700 -#define BOOST_LCAST_HAS_INT128 -#endif - // Test all 65536 values if true: bool const lcast_test_small_integral_types_completely = false; @@ -76,5 +72,5 @@ void test_conversion_from_to_ulonglong(); #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 void test_conversion_from_to_int128(); void test_conversion_from_to_uint128(); @@ -100,5 +96,5 @@ suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int128)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint128)); @@ -445,6 +441,6 @@ // 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); @@ -558,13 +554,32 @@ -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_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 @@ -603,5 +618,5 @@ #endif -#ifdef BOOST_LCAST_HAS_INT128 +#ifdef BOOST_HAS_INT128 test_integral_conversions_on_min_max_impl(); #endif Index: libs/conversion/test/Jamfile.v2 =================================================================== --- libs/conversion/test/Jamfile.v2 (revision 83689) +++ libs/conversion/test/Jamfile.v2 (revision 85160) @@ -1,4 +1,4 @@ # Copyright (C) 2001-2003 Douglas Gregor -# Copyright (C) 2011-2012 Antony Polukhin +# Copyright (C) 2011-2013 Antony Polukhin # # Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -16,4 +16,9 @@ gcc-4.6:-ftrapv clang:-ftrapv + # default to all warnings on: + all + # set warnings as errors for those compilers we know we get warning free: + gcc:-Wextra + gcc:-Wno-uninitialized ; Index: libs/conversion/test/implicit_cast_fail.cpp =================================================================== --- libs/conversion/test/implicit_cast_fail.cpp (revision 79364) +++ libs/conversion/test/implicit_cast_fail.cpp (revision 85160) @@ -20,5 +20,7 @@ { foo x = implicit_cast("foobar"); - (void)x; // warning suppression. + (void)x; // warning suppression. + BOOST_CHECK(false); // suppressing warning about 'boost::unit_test::{anonymous}::unit_test_log' defined but not used return 0; } + Index: libs/conversion/test/lexical_cast_to_pointer_test.cpp =================================================================== --- libs/conversion/test/lexical_cast_to_pointer_test.cpp (revision 83689) +++ libs/conversion/test/lexical_cast_to_pointer_test.cpp (revision 85160) @@ -18,4 +18,6 @@ { boost::lexical_cast("Hello"); + BOOST_CHECK(false); // suppressing warning about 'boost::unit_test::{anonymous}::unit_test_log' defined but not used return 0; } + Index: libs/conversion/index.html =================================================================== --- libs/conversion/index.html (revision 73851) +++ libs/conversion/index.html (revision 85160) @@ -7,4 +7,11 @@ Boost Conversion Library + @@ -33,5 +40,9 @@ S-Format="%d %B, %Y" startspan -->June 23, 2005

- + Index: libs/conversion/numeric_cast_test.cpp =================================================================== --- libs/conversion/numeric_cast_test.cpp (revision 80409) +++ libs/conversion/numeric_cast_test.cpp (revision 85160) @@ -49,5 +49,5 @@ signed char c = 0; - c = large_value; // see if compiler generates warning + c = static_cast(large_value); c = numeric_cast( small_value );