From 7b8e3d01def3b8438962247e083ce945d2ff4219 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 2 Jun 2016 23:52:23 +0100 Subject: [PATCH 1/8] Use argument SFINAE instead of return SFINAE --- doc/changes.qbk | 2 ++ include/boost/unordered/detail/equivalent.hpp | 8 ++++---- include/boost/unordered/detail/util.hpp | 10 ++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/changes.qbk b/doc/changes.qbk index 839b370f..54002878 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -276,5 +276,7 @@ C++11 support has resulted in some breaking changes: * Remove `BOOST_UNORDERED_DEPRECATED_EQUALITY` warning. * Simpler implementation of assignment, fixes an exception safety issue for `unordered_multiset` and `unordered_multimap`. Might be a little slower. +* Stop using return value SFINAE which some older compilers have issues + with. [endsect] diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index 407b5f79..b7b40f1a 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -484,8 +484,8 @@ namespace boost { namespace unordered { namespace detail { // if hash function throws, or inserting > 1 element, basic exception // safety. Strong otherwise template - typename boost::unordered::detail::enable_if_forward::type - insert_range(I i, I j) + void insert_range(I i, I j, typename + boost::unordered::detail::enable_if_forward::type = 0) { if(i == j) return; @@ -508,8 +508,8 @@ namespace boost { namespace unordered { namespace detail { } template - typename boost::unordered::detail::disable_if_forward::type - insert_range(I i, I j) + void insert_range(I i, I j, typename + boost::unordered::detail::disable_if_forward::type = 0) { node_constructor a(this->node_alloc()); for (; i != j; ++i) { diff --git a/include/boost/unordered/detail/util.hpp b/include/boost/unordered/detail/util.hpp index 14dcfd84..0a406c85 100644 --- a/include/boost/unordered/detail/util.hpp +++ b/include/boost/unordered/detail/util.hpp @@ -125,17 +125,15 @@ namespace boost { namespace unordered { namespace detail { // insert_size/initial_size template - inline typename - boost::unordered::detail::enable_if_forward::type - insert_size(I i, I j) + inline std::size_t insert_size(I i, I j, typename + boost::unordered::detail::enable_if_forward::type = 0) { return std::distance(i, j); } template - inline typename - boost::unordered::detail::disable_if_forward::type - insert_size(I, I) + inline std::size_t insert_size(I, I, typename + boost::unordered::detail::disable_if_forward::type = 0) { return 1; } From 3720b0be584bd7dc022989f717b7a193f81b4fb9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 1 Jul 2016 11:12:29 +0100 Subject: [PATCH 2/8] Try creating a project for test. For some reason the unordered test results are not showing up any more. This is odd, as when I try locally they do run. I don't know why this is, but it's possible that it's because there isn't an actual project in the test directory, so try adding one. --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a6ab923c..a7cd39a5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -3,7 +3,7 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -import testing ; +project unordered-test ; build-project unordered ; build-project exception ; From 21f2522695fe92a5668f895661539659465ae4fe Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 2 Jul 2016 22:11:43 +0100 Subject: [PATCH 3/8] Try running the tests from unordered/test. --- test/Jamfile.v2 | 60 ++++++++++++++++++++++++++++++++++++- test/unordered/Jamfile.v2 | 63 --------------------------------------- 2 files changed, 59 insertions(+), 64 deletions(-) delete mode 100644 test/unordered/Jamfile.v2 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a7cd39a5..54b4cc22 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -5,5 +5,63 @@ project unordered-test ; -build-project unordered ; +import testing ; + +project unordered-test/unordered + : requirements + all + intel:on + # Would be nice to define -Wundef, but I'm getting warnings from + # Boost.Preprocessor on trunk. + gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow -Wno-long-long" + darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" + ; + +test-suite unordered + : + [ run unordered/fwd_set_test.cpp ] + [ run unordered/fwd_map_test.cpp ] + [ run unordered/allocator_traits.cpp ] + [ run unordered/minimal_allocator.cpp ] + [ run unordered/compile_set.cpp ] + [ run unordered/compile_map.cpp ] + [ run unordered/noexcept_tests.cpp ] + [ run unordered/link_test_1.cpp unordered/link_test_2.cpp ] + [ run unordered/incomplete_test.cpp ] + [ run unordered/simple_tests.cpp ] + [ run unordered/equivalent_keys_tests.cpp ] + [ run unordered/constructor_tests.cpp ] + [ run unordered/copy_tests.cpp ] + [ run unordered/move_tests.cpp ] + [ run unordered/assign_tests.cpp ] + [ run unordered/insert_tests.cpp ] + [ run unordered/insert_stable_tests.cpp ] + [ run unordered/unnecessary_copy_tests.cpp ] + [ run unordered/erase_tests.cpp ] + [ run unordered/erase_equiv_tests.cpp ] + [ run unordered/find_tests.cpp ] + [ run unordered/at_tests.cpp ] + [ run unordered/bucket_tests.cpp ] + [ run unordered/load_factor_tests.cpp ] + [ run unordered/rehash_tests.cpp ] + [ run unordered/equality_tests.cpp ] + [ run unordered/swap_tests.cpp ] + + [ run unordered/compile_set.cpp : : + : BOOST_UNORDERED_USE_MOVE + : bmove_compile_set ] + [ run unordered/compile_map.cpp : : + : BOOST_UNORDERED_USE_MOVE + : bmove_compile_map ] + [ run unordered/copy_tests.cpp : : + : BOOST_UNORDERED_USE_MOVE + : bmove_copy ] + [ run unordered/move_tests.cpp : : + : BOOST_UNORDERED_USE_MOVE + : bmove_move ] + [ run unordered/assign_tests.cpp : : + : BOOST_UNORDERED_USE_MOVE + : bmove_assign ] + ; + build-project exception ; diff --git a/test/unordered/Jamfile.v2 b/test/unordered/Jamfile.v2 deleted file mode 100644 index 460ef135..00000000 --- a/test/unordered/Jamfile.v2 +++ /dev/null @@ -1,63 +0,0 @@ - -# Copyright 2006-2008 Daniel James. -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -import testing ; - -project unordered-test/unordered - : requirements - all - intel:on - # Would be nice to define -Wundef, but I'm getting warnings from - # Boost.Preprocessor on trunk. - gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow -Wno-long-long" - darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" - ; - -test-suite unordered - : - [ run fwd_set_test.cpp ] - [ run fwd_map_test.cpp ] - [ run allocator_traits.cpp ] - [ run minimal_allocator.cpp ] - [ run compile_set.cpp ] - [ run compile_map.cpp ] - [ run noexcept_tests.cpp ] - [ run link_test_1.cpp link_test_2.cpp ] - [ run incomplete_test.cpp ] - [ run simple_tests.cpp ] - [ run equivalent_keys_tests.cpp ] - [ run constructor_tests.cpp ] - [ run copy_tests.cpp ] - [ run move_tests.cpp ] - [ run assign_tests.cpp ] - [ run insert_tests.cpp ] - [ run insert_stable_tests.cpp ] - [ run unnecessary_copy_tests.cpp ] - [ run erase_tests.cpp ] - [ run erase_equiv_tests.cpp ] - [ run find_tests.cpp ] - [ run at_tests.cpp ] - [ run bucket_tests.cpp ] - [ run load_factor_tests.cpp ] - [ run rehash_tests.cpp ] - [ run equality_tests.cpp ] - [ run swap_tests.cpp ] - - [ run compile_set.cpp : : - : BOOST_UNORDERED_USE_MOVE - : bmove_compile_set ] - [ run compile_map.cpp : : - : BOOST_UNORDERED_USE_MOVE - : bmove_compile_map ] - [ run copy_tests.cpp : : - : BOOST_UNORDERED_USE_MOVE - : bmove_copy ] - [ run move_tests.cpp : : - : BOOST_UNORDERED_USE_MOVE - : bmove_move ] - [ run assign_tests.cpp : : - : BOOST_UNORDERED_USE_MOVE - : bmove_assign ] - ; From 59cbe3d48392deffc32d502be9ce1dbfcbd99c10 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 3 Jul 2016 08:39:45 +0100 Subject: [PATCH 4/8] Also move exception tests into test/Jamfile.v2 Moving the tests successfully restored the test results, so do it for the exception tests as well. --- test/Jamfile.v2 | 17 ++++++++++++++--- test/exception/Jamfile.v2 | 29 ----------------------------- 2 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 test/exception/Jamfile.v2 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 54b4cc22..6f844095 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -3,8 +3,6 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -project unordered-test ; - import testing ; project unordered-test/unordered @@ -17,6 +15,9 @@ project unordered-test/unordered darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" ; +#alias framework : /boost/test//boost_unit_test_framework ; +alias framework : ; + test-suite unordered : [ run unordered/fwd_set_test.cpp ] @@ -64,4 +65,14 @@ test-suite unordered : bmove_assign ] ; -build-project exception ; +test-suite unordered-exception + : + [ run exception/constructor_exception_tests.cpp framework ] + [ run exception/copy_exception_tests.cpp framework ] + [ run exception/assign_exception_tests.cpp framework ] + [ run exception/insert_exception_tests.cpp framework ] + [ run exception/erase_exception_tests.cpp framework ] + [ run exception/rehash_exception_tests.cpp framework ] + [ run exception/swap_exception_tests.cpp framework : : : + BOOST_UNORDERED_SWAP_METHOD=2 ] + ; diff --git a/test/exception/Jamfile.v2 b/test/exception/Jamfile.v2 deleted file mode 100644 index c5d6f403..00000000 --- a/test/exception/Jamfile.v2 +++ /dev/null @@ -1,29 +0,0 @@ - -# Copyright 2006-2008 Daniel James. -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -import testing ; - -#alias framework : /boost/test//boost_unit_test_framework ; -alias framework : ; - -project unordered-test/exception-tests - : requirements - all - intel:on - gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow -Wno-long-long" - darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" - ; - -test-suite unordered-exception - : - [ run constructor_exception_tests.cpp framework ] - [ run copy_exception_tests.cpp framework ] - [ run assign_exception_tests.cpp framework ] - [ run insert_exception_tests.cpp framework ] - [ run erase_exception_tests.cpp framework ] - [ run rehash_exception_tests.cpp framework ] - [ run swap_exception_tests.cpp framework : : : - BOOST_UNORDERED_SWAP_METHOD=2 ] - ; From 1bca2df6422eea1002b8773b0147e4ad19490913 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 3 Jul 2016 08:41:52 +0100 Subject: [PATCH 5/8] Always explicitly specify standard for travis. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a005cd16..b3768472 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,9 @@ matrix: before_script: - | - echo "using gcc : : g++-4.8 ;" > ~/user-config.jam + echo "using gcc : : g++-4.8 --std=c++03 ;" > ~/user-config.jam echo "using gcc : std11 : g++-4.8 --std=c++11 ;" >> ~/user-config.jam - echo "using clang : : clang++ ;" >> ~/user-config.jam + echo "using clang : : clang++ --std=c++03 " >> ~/user-config.jam echo "using clang : std11 : clang++ --std=c++11 ;" >> ~/user-config.jam - cat ~/user-config.jam - touch Jamroot.jam From 6bc57bd398d3d20d69f833c4fe093f98cacecb43 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 3 Jul 2016 08:46:40 +0100 Subject: [PATCH 6/8] Typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b3768472..732a983f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: - | echo "using gcc : : g++-4.8 --std=c++03 ;" > ~/user-config.jam echo "using gcc : std11 : g++-4.8 --std=c++11 ;" >> ~/user-config.jam - echo "using clang : : clang++ --std=c++03 " >> ~/user-config.jam + echo "using clang : : clang++ --std=c++03 ;" >> ~/user-config.jam echo "using clang : std11 : clang++ --std=c++11 ;" >> ~/user-config.jam - cat ~/user-config.jam - touch Jamroot.jam From bc601e34d25081eddc2ab6591ee1b1a6f03ef108 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 25 Jul 2016 14:18:39 +0100 Subject: [PATCH 7/8] More info on test failure on intel-linux. The count check is reporting errors, but everything else appears to work okay. --- test/unordered/erase_tests.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unordered/erase_tests.cpp b/test/unordered/erase_tests.cpp index 4135af4d..9c737bd8 100644 --- a/test/unordered/erase_tests.cpp +++ b/test/unordered/erase_tests.cpp @@ -95,12 +95,16 @@ void erase_tests1(Container*, test::random_generator generator) BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*pos); std::size_t count = x.count(key); + BOOST_TEST(count > 0); BOOST_TEST(next == x.erase(pos)); --size; if(size > 0) BOOST_TEST(index == 0 ? next == x.begin() : next == boost::next(prev)); BOOST_TEST(x.count(key) == count - 1); + if (x.count(key) != count - 1) { + std::cerr << count << " => " << x.count(key) << std::endl; + } BOOST_TEST(x.size() == size); if (++iterations % 20 == 0) test::check_equivalent_keys(x); } @@ -180,12 +184,16 @@ void erase_tests1(Container*, test::random_generator generator) BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*pos); std::size_t count = x.count(key); + BOOST_TEST(count > 0); x.quick_erase(pos); --size; if(size > 0) BOOST_TEST(index == 0 ? next == x.begin() : next == boost::next(prev)); BOOST_TEST(x.count(key) == count - 1); + if (x.count(key) != count - 1) { + std::cerr << count << " => " << x.count(key) << std::endl; + } BOOST_TEST(x.size() == size); if (++iterations % 20 == 0) test::check_equivalent_keys(x); } From 2be69b3eb91898a6910eb68d10b64a83dc77da04 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 27 Jul 2016 06:51:05 +0100 Subject: [PATCH 8/8] A little more information in the find_tests. Now the intel-linux tester that was failing for erase_tests is passing, but has started failing for find_tests instead. Oddly the test for non-const find is failing, but the const find is fine - this doesn't make much sense as they should be the same. Not sure, but it suggests the problem might be in the way iterators are handled, rather than the data structure? Checking the iterators before checking that the keys are equal in order to tell which part of the test is failing. --- test/unordered/find_tests.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unordered/find_tests.cpp b/test/unordered/find_tests.cpp index a310d40c..45151e99 100644 --- a/test/unordered/find_tests.cpp +++ b/test/unordered/find_tests.cpp @@ -40,8 +40,10 @@ void find_tests1(X*, test::random_generator generator) iterator pos = x.find(key); BOOST_DEDUCED_TYPENAME X::const_iterator const_pos = x_const.find(key); + BOOST_TEST(pos != x.end()); BOOST_TEST(pos != x.end() && x.key_eq()(key, test::get_key(*pos))); + BOOST_TEST(const_pos != x_const.end()); BOOST_TEST(const_pos != x_const.end() && x_const.key_eq()(key, test::get_key(*const_pos)));