Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57537 - in trunk: boost/functional/hash libs/functional/hash/test libs/unordered/test/exception libs/unordered/test/helpers libs/unordered/test/unordered
From: daniel_james_at_[hidden]
Date: 2009-11-10 03:15:58


Author: danieljames
Date: 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
New Revision: 57537
URL: http://svn.boost.org/trac/boost/changeset/57537

Log:
Stricter warnings for unordered and hash.

There are still warnings in hash_complex_test.
Text files modified:
   trunk/boost/functional/hash/hash.hpp | 13 ++++++++++
   trunk/libs/functional/hash/test/Jamfile.v2 | 18 ++++++++++---
   trunk/libs/functional/hash/test/hash_no_ext_fail_test.cpp | 3 ++
   trunk/libs/unordered/test/exception/Jamfile.v2 | 13 +++++++++
   trunk/libs/unordered/test/exception/assign_exception_tests.cpp | 4 +++
   trunk/libs/unordered/test/exception/swap_exception_tests.cpp | 4 +++
   trunk/libs/unordered/test/helpers/exception_test.hpp | 3 ++
   trunk/libs/unordered/test/helpers/input_iterator.hpp | 2 +
   trunk/libs/unordered/test/helpers/list.hpp | 19 +++++++++++++
   trunk/libs/unordered/test/helpers/strong.hpp | 2
   trunk/libs/unordered/test/helpers/tracker.hpp | 4 +-
   trunk/libs/unordered/test/unordered/Jamfile.v2 | 10 +++++--
   trunk/libs/unordered/test/unordered/equality_tests.cpp | 52 ++++++++++++++++++++--------------------
   trunk/libs/unordered/test/unordered/erase_tests.cpp | 2
   14 files changed, 109 insertions(+), 40 deletions(-)

Modified: trunk/boost/functional/hash/hash.hpp
==============================================================================
--- trunk/boost/functional/hash/hash.hpp (original)
+++ trunk/boost/functional/hash/hash.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -197,6 +197,15 @@
         return x + (x >> 3);
     }
 
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#if BOOST_MSVC == 1400
+#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to 'unsigned int',
+ // possible loss of data
+ // A misguided attempt to detect 64-bit incompatability.
+#endif
+#endif
+
 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
     template <class T>
     inline void hash_combine(std::size_t& seed, T& v)
@@ -209,6 +218,10 @@
         seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
     }
 
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
     template <class It>
     inline std::size_t hash_range(It first, It last)
     {

Modified: trunk/libs/functional/hash/test/Jamfile.v2
==============================================================================
--- trunk/libs/functional/hash/test/Jamfile.v2 (original)
+++ trunk/libs/functional/hash/test/Jamfile.v2 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -7,9 +7,16 @@
 
 project hash-tests
     : requirements
+ <warnings>all
+ <toolset>intel:<warnings>on
+ <toolset>intel:<cxxflags>-strict-ansi
+ <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+ <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
         <toolset>gcc:<define>_GLIBCXX_DEBUG
- <toolset>gcc:<cxxflags>-Wsign-promo
- #<toolset>gcc:<cxxflags>-Wextra
+ <toolset>darwin:<define>_GLIBCXX_DEBUG
+ <toolset>msvc:<warnings-as-errors>on
+ <toolset>gcc:<warnings-as-errors>on
+ <toolset>darwin:<warnings-as-errors>on
     ;
 
 test-suite functional/hash
@@ -33,13 +40,14 @@
         [ run hash_deque_test.cpp ]
         [ run hash_set_test.cpp ]
         [ run hash_map_test.cpp ]
- [ run hash_complex_test.cpp ]
+ [ run hash_complex_test.cpp : : : <warnings-as-errors>off ]
         [ run link_test.cpp link_test_2.cpp ]
         [ run link_ext_test.cpp link_no_ext_test.cpp ]
         [ run extensions_hpp_test.cpp ]
         [ run container_fwd_test.cpp ]
- [ compile-fail hash_no_ext_fail_test.cpp ]
- [ compile-fail namespace_fail_test.cpp ]
+ # Don't want compile-fail tests to fail because of warnings.
+ [ compile-fail hash_no_ext_fail_test.cpp : : : <warnings-as-errors>off ]
+ [ compile-fail namespace_fail_test.cpp : : : <warnings-as-errors>off ]
         [ run hash_no_ext_macro_1.cpp ]
         [ run hash_no_ext_macro_2.cpp ]
     ;

Modified: trunk/libs/functional/hash/test/hash_no_ext_fail_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_no_ext_fail_test.cpp (original)
+++ trunk/libs/functional/hash/test/hash_no_ext_fail_test.cpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -12,8 +12,11 @@
 #include <boost/functional/hash.hpp>
 #include <boost/functional/hash.hpp>
 
+template <class T> void ignore(T const&) {}
+
 int main()
 {
     HASH_NAMESPACE::hash< int[10] > hasher;
+ ignore(hasher);
     return 0;
 }

Modified: trunk/libs/unordered/test/exception/Jamfile.v2
==============================================================================
--- trunk/libs/unordered/test/exception/Jamfile.v2 (original)
+++ trunk/libs/unordered/test/exception/Jamfile.v2 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -8,7 +8,18 @@
 #alias framework : /boost/test//boost_unit_test_framework ;
 alias framework : ;
 
-project unordered-test/exception-tests ;
+project unordered-test/exception-tests
+ : requirements
+ <warnings>all
+ <toolset>intel:<warnings>on
+ <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+ <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+ <toolset>gcc:<define>_GLIBCXX_DEBUG
+ <toolset>darwin:<define>_GLIBCXX_DEBUG
+ <toolset>msvc:<warnings-as-errors>on
+ <toolset>gcc:<warnings-as-errors>on
+ <toolset>darwin:<warnings-as-errors>on
+ ;
 
 test-suite unordered-exception
     :

Modified: trunk/libs/unordered/test/exception/assign_exception_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/exception/assign_exception_tests.cpp (original)
+++ trunk/libs/unordered/test/exception/assign_exception_tests.cpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -7,6 +7,10 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/invariants.hpp"
 
+#if defined(BOOST_MSVC)
+#pragma warning(disable:4512) // assignment operator could not be generated
+#endif
+
 test::seed_t seed(12847);
 
 template <class T>

Modified: trunk/libs/unordered/test/exception/swap_exception_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/exception/swap_exception_tests.cpp (original)
+++ trunk/libs/unordered/test/exception/swap_exception_tests.cpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -7,6 +7,10 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/invariants.hpp"
 
+#if defined(BOOST_MSVC)
+#pragma warning(disable:4512) // assignment operator could not be generated
+#endif
+
 test::seed_t seed(9387);
 
 template <class T>

Modified: trunk/libs/unordered/test/helpers/exception_test.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/exception_test.hpp (original)
+++ trunk/libs/unordered/test/helpers/exception_test.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -143,6 +143,9 @@
     class test_runner
     {
         Test const& test_;
+
+ test_runner(test_runner const&);
+ test_runner& operator=(test_runner const&);
     public:
         test_runner(Test const& t) : test_(t) {}
         void operator()() const {

Modified: trunk/libs/unordered/test/helpers/input_iterator.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/input_iterator.hpp (original)
+++ trunk/libs/unordered/test/helpers/input_iterator.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -21,6 +21,8 @@
         operator value_type const&() const { return v_; }
         
         value_type v_;
+ private:
+ proxy& operator=(proxy const&);
     };
 
     template <class Iterator>

Modified: trunk/libs/unordered/test/helpers/list.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/list.hpp (original)
+++ trunk/libs/unordered/test/helpers/list.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -17,6 +17,23 @@
 
 namespace test
 {
+ template <typename It1, typename It2>
+ bool equal(It1 begin, It1 end, It2 compare)
+ {
+ for(;begin != end; ++begin, ++compare)
+ if(*begin != *compare) return false;
+ return true;
+ }
+
+ template <typename It1, typename It2, typename Pred>
+ bool equal(It1 begin, It1 end, It2 compare, Pred predicate)
+ {
+ for(;begin != end; ++begin, ++compare)
+ if(!predicate(*begin, *compare)) return false;
+ return true;
+ }
+
+
     template <typename T> class list;
 
     namespace test_detail
@@ -222,7 +239,7 @@
 
         bool operator==(list const& y) const {
             return size() == y.size() &&
- std::equal(begin(), end(), y.begin());
+ test::equal(begin(), end(), y.begin());
         }
 
         bool operator!=(list const& y) const {

Modified: trunk/libs/unordered/test/helpers/strong.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/strong.hpp (original)
+++ trunk/libs/unordered/test/helpers/strong.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -31,7 +31,7 @@
 
         void test(X const& x, unsigned int allocations = 0) const {
             if(!(x.size() == values_.size() &&
- std::equal(x.cbegin(), x.cend(), values_.begin(),
+ test::equal(x.cbegin(), x.cend(), values_.begin(),
                         test::equivalent)))
                 BOOST_ERROR("Strong exception safety failure.");
             if(allocations != allocations_)

Modified: trunk/libs/unordered/test/helpers/tracker.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/tracker.hpp (original)
+++ trunk/libs/unordered/test/helpers/tracker.hpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -50,7 +50,7 @@
         values1.sort();
         values2.sort();
         BOOST_TEST(values1.size() == values2.size() &&
- std::equal(values1.begin(), values1.end(), values2.begin(),
+ test::equal(values1.begin(), values1.end(), values2.begin(),
                     test::equivalent));
     }
 
@@ -62,7 +62,7 @@
         values1.sort();
         values2.sort();
         BOOST_TEST(values1.size() == values2.size() &&
- std::equal(values1.begin(), values1.end(), values2.begin(), test::equivalent));
+ test::equal(values1.begin(), values1.end(), values2.begin(), test::equivalent));
     }
 
     template <class X>

Modified: trunk/libs/unordered/test/unordered/Jamfile.v2
==============================================================================
--- trunk/libs/unordered/test/unordered/Jamfile.v2 (original)
+++ trunk/libs/unordered/test/unordered/Jamfile.v2 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -9,9 +9,13 @@
     : requirements
         <warnings>all
         <toolset>intel:<warnings>on
- <toolset>intel:<cxxflags>-strict-ansi
- <toolset>msvc:<cxxflags>/W4
- <toolset>gcc:<cxxflags>"-Wsign-promo -Wunused-parameter -pedantic"
+ <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+ <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter"
+ <toolset>gcc:<define>_GLIBCXX_DEBUG
+ <toolset>darwin:<define>_GLIBCXX_DEBUG
+ <toolset>msvc:<warnings-as-errors>on
+ <toolset>gcc:<warnings-as-errors>on
+ <toolset>darwin:<warnings-as-errors>on
     ;
 
 test-suite unordered

Modified: trunk/libs/unordered/test/unordered/equality_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/equality_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/equality_tests.cpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -29,36 +29,36 @@
     };
 
 #define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \
- do { \
+ { \
         boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
         BOOST_TEST(set1 op set2); \
- } while(false)
+ }
 
 #define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \
- do { \
+ { \
         boost::unordered_multiset<int, mod_compare, mod_compare> set1, set2; \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
         BOOST_TEST(set1 op set2); \
- } while(false)
+ }
 
 #define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \
- do { \
+ { \
         boost::unordered_map<int, int, mod_compare, mod_compare> map1, map2; \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
         BOOST_TEST(map1 op map2); \
- } while(false)
+ }
 
 #define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \
- do { \
+ { \
         boost::unordered_multimap<int, int, mod_compare, mod_compare> map1, map2; \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
         BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
         BOOST_TEST(map1 op map2); \
- } while(false)
+ }
 
 #define UNORDERED_SET_INSERT(r, set, item) set.insert(item);
 #define UNORDERED_MAP_INSERT(r, map, item) \
@@ -89,57 +89,57 @@
     
     UNORDERED_AUTO_TEST(equality_key_value_tests)
     {
- UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2));
- UNORDERED_EQUALITY_SET_TEST((2), ==, (2));
- UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)));
+ UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2))
+ UNORDERED_EQUALITY_SET_TEST((2), ==, (2))
+ UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)))
     }
     
     UNORDERED_AUTO_TEST(equality_collision_test)
     {
         UNORDERED_EQUALITY_MULTISET_TEST(
- (1), !=, (501));
+ (1), !=, (501))
         UNORDERED_EQUALITY_MULTISET_TEST(
- (1)(251), !=, (1)(501));
+ (1)(251), !=, (1)(501))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((251)(1))((1)(1)), !=, ((501)(1))((1)(1)));
+ ((251)(1))((1)(1)), !=, ((501)(1))((1)(1)))
         UNORDERED_EQUALITY_MULTISET_TEST(
- (1)(501), ==, (1)(501));
+ (1)(501), ==, (1)(501))
         UNORDERED_EQUALITY_SET_TEST(
- (1)(501), ==, (501)(1));
+ (1)(501), ==, (501)(1))
     }
 
     UNORDERED_AUTO_TEST(equality_group_size_test)
     {
         UNORDERED_EQUALITY_MULTISET_TEST(
- (10)(20)(20), !=, (10)(10)(20));
+ (10)(20)(20), !=, (10)(10)(20))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
             ((10)(1))((20)(1))((20)(1)), !=,
- ((10)(1))((20)(1))((10)(1)));
+ ((10)(1))((20)(1))((10)(1)))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
             ((20)(1))((10)(1))((10)(1)), ==,
- ((10)(1))((20)(1))((10)(1)));
+ ((10)(1))((20)(1))((10)(1)))
     }
     
     UNORDERED_AUTO_TEST(equality_map_value_test)
     {
         UNORDERED_EQUALITY_MAP_TEST(
- ((1)(1)), !=, ((1)(2)));
+ ((1)(1)), !=, ((1)(2)))
         UNORDERED_EQUALITY_MAP_TEST(
- ((1)(1)), ==, ((1)(1)));
+ ((1)(1)), ==, ((1)(1)))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(1)), !=, ((1)(2)));
+ ((1)(1)), !=, ((1)(2)))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(1))((1)(1)), !=, ((1)(1))((1)(2)));
+ ((1)(1))((1)(1)), !=, ((1)(1))((1)(2)))
         UNORDERED_EQUALITY_MULTIMAP_TEST(
- ((1)(2))((1)(1)), !=, ((1)(1))((1)(2)));
+ ((1)(2))((1)(1)), !=, ((1)(1))((1)(2)))
     }
 
     UNORDERED_AUTO_TEST(equality_predicate_test)
     {
         UNORDERED_EQUALITY_SET_TEST(
- (1), ==, (1001));
+ (1), ==, (1001))
         UNORDERED_EQUALITY_MAP_TEST(
- ((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)));
+ ((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)))
     }
 
     // Test that equality still works when the two containers have

Modified: trunk/libs/unordered/test/unordered/erase_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/erase_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/erase_tests.cpp 2009-11-10 03:15:55 EST (Tue, 10 Nov 2009)
@@ -65,7 +65,7 @@
         while(size > 0 && !x.empty())
         {
             using namespace std;
- int index = rand() % x.size();
+ int index = rand() % (int) x.size();
             BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
             if(index == 0) {
                 prev = pos = x.begin();


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