|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57859 - in trunk: boost boost/integer libs/integer/test
From: john_at_[hidden]
Date: 2009-11-23 05:43:01
Author: johnmaddock
Date: 2009-11-23 05:43:00 EST (Mon, 23 Nov 2009)
New Revision: 57859
URL: http://svn.boost.org/trac/boost/changeset/57859
Log:
Suppress and/or fix warnings - in particular avoid undefined behaviour in the test cases!
Text files modified:
trunk/boost/integer/integer_mask.hpp | 9 +++++++++
trunk/boost/integer_traits.hpp | 11 +++++++++++
trunk/libs/integer/test/integer_mask_test.cpp | 23 ++++++++++++++++++-----
trunk/libs/integer/test/integer_test.cpp | 4 ++++
4 files changed, 42 insertions(+), 5 deletions(-)
Modified: trunk/boost/integer/integer_mask.hpp
==============================================================================
--- trunk/boost/integer/integer_mask.hpp (original)
+++ trunk/boost/integer/integer_mask.hpp 2009-11-23 05:43:00 EST (Mon, 23 Nov 2009)
@@ -70,6 +70,11 @@
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 );
#if USHRT_MAX > UCHAR_MAX
@@ -84,6 +89,10 @@
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
#endif
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
Modified: trunk/boost/integer_traits.hpp
==============================================================================
--- trunk/boost/integer_traits.hpp (original)
+++ trunk/boost/integer_traits.hpp 2009-11-23 05:43:00 EST (Mon, 23 Nov 2009)
@@ -27,6 +27,17 @@
#include <wchar.h>
#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 {
template<class T>
Modified: trunk/libs/integer/test/integer_mask_test.cpp
==============================================================================
--- trunk/libs/integer/test/integer_mask_test.cpp (original)
+++ trunk/libs/integer/test/integer_mask_test.cpp 2009-11-23 05:43:00 EST (Mon, 23 Nov 2009)
@@ -17,6 +17,9 @@
#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< \
(v) >::high_bit == (1ul << (v)) );
@@ -25,10 +28,20 @@
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
-#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
- (v) >::sig_bits == ((1ul << (v)) - 1) );
-#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
- (v) >::sig_bits_fast == ((1ul << (v)) - 1) );
+#define PRIVATE_LOW_BITS_SLOW_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 == 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); \
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
@@ -73,7 +86,7 @@
PRIVATE_HIGH_BIT_TEST( 0 );
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( 30 );
PRIVATE_LOW_BITS_TEST( 29 );
Modified: trunk/libs/integer/test/integer_test.cpp
==============================================================================
--- trunk/libs/integer/test/integer_test.cpp (original)
+++ trunk/libs/integer/test/integer_test.cpp 2009-11-23 05:43:00 EST (Mon, 23 Nov 2009)
@@ -22,6 +22,10 @@
#include <iostream> // for std::cout (std::endl indirectly)
#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
// of the integer templates will be printed.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk