forked from boostorg/integer
Suppress and/or fix warnings - in particular avoid undefined behaviour in the test cases!
[SVN r57859]
This commit is contained in:
@ -70,6 +70,11 @@ struct low_bits_mask_t
|
|||||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
|
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
|
||||||
|
|
||||||
#if USHRT_MAX > UCHAR_MAX
|
#if USHRT_MAX > UCHAR_MAX
|
||||||
@ -84,6 +89,10 @@ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
|
|||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
|
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,17 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// We simply cannot include this header on gcc without getting copious warnings of the kind:
|
||||||
|
//
|
||||||
|
// ../../../boost/integer_traits.hpp:164:66: warning: use of C99 long long integer constant
|
||||||
|
//
|
||||||
|
// And yet there is no other reasonable implementation, so we declare this a system header
|
||||||
|
// to suppress these warnings.
|
||||||
|
//
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
#pragma GCC system_header
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
#include <iostream> // for std::cout (std::endl indirectly)
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(disable:4127) // conditional expression is constant
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
||||||
(v) >::high_bit == (1ul << (v)) );
|
(v) >::high_bit == (1ul << (v)) );
|
||||||
@ -25,10 +28,20 @@
|
|||||||
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
||||||
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
#define PRIVATE_LOW_BITS_SLOW_TEST(v) \
|
||||||
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
do{ \
|
||||||
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
unsigned long mask = 0;\
|
||||||
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
if(v > 0)\
|
||||||
|
{ mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||||
|
BOOST_CHECK( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
|
||||||
|
}while(false);
|
||||||
|
#define PRIVATE_LOW_BITS_FAST_TEST(v) \
|
||||||
|
do{ \
|
||||||
|
unsigned long mask = 0;\
|
||||||
|
if(v > 0)\
|
||||||
|
{ mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||||
|
BOOST_CHECK( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
|
||||||
|
}while(false);
|
||||||
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
||||||
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
@ -73,7 +86,7 @@ int test_main( int, char*[] )
|
|||||||
PRIVATE_HIGH_BIT_TEST( 0 );
|
PRIVATE_HIGH_BIT_TEST( 0 );
|
||||||
|
|
||||||
cout << "Doing low_bits_mask_t tests." << endl;
|
cout << "Doing low_bits_mask_t tests." << endl;
|
||||||
PRIVATE_LOW_BITS_TEST( 32 ); // Undefined behavior? Whoops!
|
PRIVATE_LOW_BITS_TEST( 32 );
|
||||||
PRIVATE_LOW_BITS_TEST( 31 );
|
PRIVATE_LOW_BITS_TEST( 31 );
|
||||||
PRIVATE_LOW_BITS_TEST( 30 );
|
PRIVATE_LOW_BITS_TEST( 30 );
|
||||||
PRIVATE_LOW_BITS_TEST( 29 );
|
PRIVATE_LOW_BITS_TEST( 29 );
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
#include <iostream> // for std::cout (std::endl indirectly)
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
#include <typeinfo> // for std::type_info
|
#include <typeinfo> // for std::type_info
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(disable:4127) // conditional expression is constant
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Control if the names of the types for each version
|
// Control if the names of the types for each version
|
||||||
// of the integer templates will be printed.
|
// of the integer templates will be printed.
|
||||||
|
Reference in New Issue
Block a user