From 991539725e5943b7f280f7ecd7a00aa7f3dc0582 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sat, 10 May 2014 18:27:59 +0400 Subject: [PATCH] Replaced left shift of signed integer values with multiplication to keep the expressions constant according to C++11. --- numeric_traits_test.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/numeric_traits_test.cpp b/numeric_traits_test.cpp index 47ee09d..ffd301c 100644 --- a/numeric_traits_test.cpp +++ b/numeric_traits_test.cpp @@ -61,18 +61,19 @@ struct complement typedef complement_traits_aux prev; public: #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 - // GCC 4.0.2 ICEs on these C-style casts + // GCC 4.0.2 ICEs on these C-style casts BOOST_STATIC_CONSTANT(Number, max = Number((prev::max) << CHAR_BIT) + Number(UCHAR_MAX)); BOOST_STATIC_CONSTANT(Number, min = Number((prev::min) << CHAR_BIT)); #else + // Avoid left shifting negative integers, use multiplication instead + BOOST_STATIC_CONSTANT(Number, shift = 1u << CHAR_BIT); BOOST_STATIC_CONSTANT(Number, max = - Number(Number(prev::max) << CHAR_BIT) + Number(Number(prev::max) * shift) + Number(UCHAR_MAX)); - BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) << CHAR_BIT)); + BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) * shift)); #endif - }; };