From e2d25b5c003abbb57b186a2d4c2aad9cfb50e0fe Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 11 Dec 2010 14:43:00 +0000 Subject: [PATCH] Avoid `-Wconversion` warnings in unordered & hash. [SVN r67170] --- hash/doc/changes.qbk | 4 ++++ hash/test/Jamfile.v2 | 4 ++-- hash/test/hash_complex_test.cpp | 2 +- hash/test/hash_number_test.cpp | 3 ++- include/boost/functional/hash/detail/hash_float_generic.hpp | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hash/doc/changes.qbk b/hash/doc/changes.qbk index eec4876..eb6572f 100644 --- a/hash/doc/changes.qbk +++ b/hash/doc/changes.qbk @@ -119,4 +119,8 @@ it's opt-in for now. This, or something like it, will become the default in a future version. +[h2 Boost 1.46.0] + +* Avoid warning due with gcc's `-Wconversion` flag. + [endsect] diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 index de35142..8985875 100644 --- a/hash/test/Jamfile.v2 +++ b/hash/test/Jamfile.v2 @@ -11,8 +11,8 @@ project hash-tests 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:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" + darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" msvc:on #gcc:on #darwin:on diff --git a/hash/test/hash_complex_test.cpp b/hash/test/hash_complex_test.cpp index a2a2dc2..67e2aff 100644 --- a/hash/test/hash_complex_test.cpp +++ b/hash/test/hash_complex_test.cpp @@ -69,7 +69,7 @@ void complex_float_tests(Float*) generic_complex_tests(complex(0.5,0)); generic_complex_tests(complex(25,0)); generic_complex_tests(complex(25,0)); - generic_complex_tests(complex(-67.5324535,56.23578678)); + generic_complex_tests(complex(static_cast(-67.5324535),static_cast(56.23578678))); } template diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 91b9b92..1080860 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -113,7 +113,8 @@ void poor_quality_tests(T*) if(T(1) != T(2)) BOOST_TEST(x1(T(1)) != x2(T(2))); if((limits::max)() != (limits::max)() - 1) - BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1)); + BOOST_TEST(x1(static_cast((limits::max)())) + != x2(static_cast((limits::max)() - 1))); } void bool_test() diff --git a/include/boost/functional/hash/detail/hash_float_generic.hpp b/include/boost/functional/hash/detail/hash_float_generic.hpp index fdbf53f..1278c2f 100644 --- a/include/boost/functional/hash/detail/hash_float_generic.hpp +++ b/include/boost/functional/hash/detail/hash_float_generic.hpp @@ -53,7 +53,7 @@ namespace boost v = ldexp(v, limits::digits); std::size_t seed = static_cast(v); - v -= seed; + v -= static_cast(seed); // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1; std::size_t const length @@ -66,7 +66,7 @@ namespace boost { v = ldexp(v, limits::digits); std::size_t part = static_cast(v); - v -= part; + v -= static_cast(part); hash_float_combine(seed, part); }