diff --git a/examples/books.cpp b/examples/books.cpp index d54b353..40feae3 100644 --- a/examples/books.cpp +++ b/examples/books.cpp @@ -20,6 +20,7 @@ int main() boost::hash book_hasher; std::size_t knife_hash_value = book_hasher(knife); + (void)knife_hash_value; // suppress unused variable warning // If std::unordered_set was available: // diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 6784f3e..697cb41 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -197,6 +197,15 @@ namespace boost 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 inline void hash_combine(std::size_t& seed, T& v) @@ -209,6 +218,10 @@ namespace boost seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + template inline std::size_t hash_range(It first, It last) { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ea19365..bff1622 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,9 +7,16 @@ import testing ; project hash-tests : requirements + all + intel:on + intel:-strict-ansi + gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter" + darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter" gcc:_GLIBCXX_DEBUG - gcc:-Wsign-promo - #gcc:-Wextra + darwin:_GLIBCXX_DEBUG + msvc:on + gcc:on + darwin:on ; test-suite functional/hash diff --git a/test/config.hpp b/test/config.hpp index 1fd0f5f..893f456 100644 --- a/test/config.hpp +++ b/test/config.hpp @@ -12,3 +12,9 @@ # define TEST_EXTENSIONS # endif #endif + +#if defined(_WIN32_WCE) +// The standard windows mobile headers trigger this warning so I disable it +// before doing anything else. +#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union +#endif diff --git a/test/container_fwd_test.cpp b/test/container_fwd_test.cpp index 87f5b90..a63c086 100644 --- a/test/container_fwd_test.cpp +++ b/test/container_fwd_test.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #include #if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) diff --git a/test/extensions_hpp_test.cpp b/test/extensions_hpp_test.cpp index 182ec01..c27981a 100644 --- a/test/extensions_hpp_test.cpp +++ b/test/extensions_hpp_test.cpp @@ -8,6 +8,8 @@ // It probably should be in boost/functional/hash/detail, but since it isn't it // should work. +#include "./config.hpp" + #include int main() { diff --git a/test/hash_complex_test.cpp b/test/hash_complex_test.cpp index f791391..3d7c200 100644 --- a/test/hash_complex_test.cpp +++ b/test/hash_complex_test.cpp @@ -19,20 +19,21 @@ int main() {} #include +#if defined(BOOST_MSVC) +#pragma warning(disable:4244) // conversion from 'unsigned long' to 'unsigned short', possible loss of data +#pragma warning(disable:4245) // conversion from 'int' to 'const unsigned short', signed/unsigned mismatch +#pragma warning(disable:4305) // truncation from 'double' to 'const std::complex::_Ty' +#pragma warning(disable:4309) // truncation of constant value +#pragma warning(disable:4512) // assignment operator could not be generated +#if BOOST_MSVC < 1400 +#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data +#endif +#endif + #include #include #include -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4244) // conversion from 'unsigned long' to 'unsigned short', possible loss of data -#pragma warning(disable:4512) // assignment operator could not be generated -#endif - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - template void generic_complex_tests(std::complex v) { @@ -80,13 +81,17 @@ void complex_integral_tests(Integer*) int main() { + // I've comments out the short and unsigned short tests + // as they cause warnings and don't really test + // anything that the other tests already deal with. + complex_float_tests((float*) 0); complex_float_tests((double*) 0); complex_float_tests((long double*) 0); - complex_integral_tests((short*) 0); + //complex_integral_tests((short*) 0); complex_integral_tests((int*) 0); complex_integral_tests((long*) 0); - complex_integral_tests((unsigned short*) 0); + //complex_integral_tests((unsigned short*) 0); complex_integral_tests((unsigned int*) 0); complex_integral_tests((unsigned long*) 0); diff --git a/test/hash_custom_test.cpp b/test/hash_custom_test.cpp index 9943d0c..fb37d91 100644 --- a/test/hash_custom_test.cpp +++ b/test/hash_custom_test.cpp @@ -3,6 +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) +#include "./config.hpp" #include #include diff --git a/test/hash_float_test.hpp b/test/hash_float_test.hpp index b1c19fc..ab3cbf2 100644 --- a/test/hash_float_test.hpp +++ b/test/hash_float_test.hpp @@ -23,6 +23,10 @@ #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4127) // conditional expression is constant +#pragma warning(disable:4723) // conditional expression is constant +#if BOOST_MSVC < 1400 +#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data +#endif #endif char const* float_type(float*) { return "float"; } diff --git a/test/hash_friend_test.cpp b/test/hash_friend_test.cpp index cac4c7f..8a493e2 100644 --- a/test/hash_friend_test.cpp +++ b/test/hash_friend_test.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #include #include diff --git a/test/hash_fwd_test_1.cpp b/test/hash_fwd_test_1.cpp index e9a1cd8..6c7f8d3 100644 --- a/test/hash_fwd_test_1.cpp +++ b/test/hash_fwd_test_1.cpp @@ -5,6 +5,8 @@ // This checks that template code implemented using hash_fwd will work. +#include "./config.hpp" + #include "./hash_fwd_test.hpp" #include diff --git a/test/hash_fwd_test_2.cpp b/test/hash_fwd_test_2.cpp index cf6e163..869f67b 100644 --- a/test/hash_fwd_test_2.cpp +++ b/test/hash_fwd_test_2.cpp @@ -6,6 +6,8 @@ // This test just makes sure a header which uses hash_fwd can compile without // the main hash headers. +#include "./config.hpp" + #if !defined(TEST_EXTENSIONS) || defined(TEST_STD_INCLUDES) int main() {} diff --git a/test/hash_global_namespace_test.cpp b/test/hash_global_namespace_test.cpp index a45278c..ccb99e7 100644 --- a/test/hash_global_namespace_test.cpp +++ b/test/hash_global_namespace_test.cpp @@ -6,6 +6,8 @@ // This test demonstrates an ADL bug in Borland 5.5 where ADL isn't performed // in the global namespace. +#include "./config.hpp" + #include #include diff --git a/test/hash_no_ext_fail_test.cpp b/test/hash_no_ext_fail_test.cpp index ef7ae96..22f6f5a 100644 --- a/test/hash_no_ext_fail_test.cpp +++ b/test/hash_no_ext_fail_test.cpp @@ -3,17 +3,26 @@ // 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) -#define HASH_NAMESPACE boost +#include "./config.hpp" // Simple test to make sure BOOST_HASH_NO_EXTENSIONS does disable extensions // (or at least one of them). -#define BOOST_HASH_NO_EXTENSIONS +#if !defined(BOOST_HASH_NO_EXTENSIONS) +# define BOOST_HASH_NO_EXTENSIONS +#endif -#include -#include +#ifdef TEST_STD_INCLUDES +# include +#else +# include +#endif + +template void ignore(T const&) {} int main() { HASH_NAMESPACE::hash< int[10] > hasher; + ignore(hasher); + return 0; } diff --git a/test/hash_no_ext_macro_1.cpp b/test/hash_no_ext_macro_1.cpp index 1d238c0..ea727bb 100644 --- a/test/hash_no_ext_macro_1.cpp +++ b/test/hash_no_ext_macro_1.cpp @@ -3,24 +3,27 @@ // 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) -#define HASH_NAMESPACE boost +#include "./config.hpp" + +#if defined(TEST_EXTENSIONS) // Include header without BOOST_HASH_NO_EXTENSIONS defined -#if defined(BOOST_HASH_NO_EXTENSIONS) -#undef BOOST_HASH_NO_EXTENSIONS -#endif -#include +# if defined(BOOST_HASH_NO_EXTENSIONS) +# undef BOOST_HASH_NO_EXTENSIONS +# endif +# include // Include header with BOOST_HASH_NO_EXTENSIONS defined -#define BOOST_HASH_NO_EXTENSIONS -#include +# define BOOST_HASH_NO_EXTENSIONS +# include +#endif #include #include -#include int main() { +#if defined(TEST_EXTENSIONS) std::deque x; x.push_back(1); @@ -28,6 +31,7 @@ int main() HASH_NAMESPACE::hash > hasher; BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); +#endif return boost::report_errors(); } diff --git a/test/hash_no_ext_macro_2.cpp b/test/hash_no_ext_macro_2.cpp index 6ab083e..a8d8c65 100644 --- a/test/hash_no_ext_macro_2.cpp +++ b/test/hash_no_ext_macro_2.cpp @@ -3,23 +3,27 @@ // 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) -#define HASH_NAMESPACE boost +#include "./config.hpp" + +#if defined(TEST_EXTENSIONS) // Include header with BOOST_HASH_NO_EXTENSIONS defined -#if !defined(BOOST_HASH_NO_EXTENSIONS) -#define BOOST_HASH_NO_EXTENSIONS -#endif -#include +# if !defined(BOOST_HASH_NO_EXTENSIONS) +# define BOOST_HASH_NO_EXTENSIONS +# endif +# include // Include header without BOOST_HASH_NO_EXTENSIONS defined -#undef BOOST_HASH_NO_EXTENSIONS -#include +# undef BOOST_HASH_NO_EXTENSIONS +# include +#endif #include #include int main() { +#if defined(TEST_EXTENSIONS) std::map x; x.insert(std::map::value_type(53, -42)); @@ -27,6 +31,7 @@ int main() HASH_NAMESPACE::hash > hasher; BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); +#endif return boost::report_errors(); } diff --git a/test/link_ext_test.cpp b/test/link_ext_test.cpp index d334035..c0e224c 100644 --- a/test/link_ext_test.cpp +++ b/test/link_ext_test.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #define HASH_NAMESPACE boost #include #include diff --git a/test/link_no_ext_test.cpp b/test/link_no_ext_test.cpp index 7f46984..c2e6869 100644 --- a/test/link_no_ext_test.cpp +++ b/test/link_no_ext_test.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #define HASH_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS #include diff --git a/test/link_test.cpp b/test/link_test.cpp index 37f9ee1..bdae262 100644 --- a/test/link_test.cpp +++ b/test/link_test.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #include extern int f(); diff --git a/test/link_test_2.cpp b/test/link_test_2.cpp index f32065c..1beffc8 100644 --- a/test/link_test_2.cpp +++ b/test/link_test_2.cpp @@ -3,6 +3,8 @@ // 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) +#include "./config.hpp" + #include int f() { return 0; } diff --git a/test/namespace_fail_test.cpp b/test/namespace_fail_test.cpp index 711ddd0..1db9fc6 100644 --- a/test/namespace_fail_test.cpp +++ b/test/namespace_fail_test.cpp @@ -6,6 +6,8 @@ // Check that I haven't inadvertantly pulled namespace std into the global // namespace. +#include "./config.hpp" + #include #include