diff --git a/test/promote_integral.cpp b/test/promote_integral.cpp index 4178ef812..590d5571e 100644 --- a/test/promote_integral.cpp +++ b/test/promote_integral.cpp @@ -14,6 +14,7 @@ // - Remove support for boost::multiprecision types // - Remove support for 128-bit integer types // - Update and sort includes +// - Add explicit conversions to avoid warnings due to implicit integral promotions // #include @@ -46,7 +47,7 @@ struct absolute_value { static inline T apply(T const& t) { - return t < 0 ? -t : t; + return static_cast(t < 0 ? -t : t); } }; @@ -73,11 +74,12 @@ struct test_max_values // but to avoid warning: comparing floating point with == is unsafe. Promoted min_value = (std::numeric_limits::min)(); - min_value *= min_value; + // Explicit casts to avoid warning: conversion to short int from int may alter its value + min_value = static_cast(min_value * min_value); BOOST_CHECK(absolute_value::apply(min_value) >= min_value); BOOST_CHECK(absolute_value::apply(min_value) <= min_value); Promoted max_value = (std::numeric_limits::max)(); - max_value *= max_value; + max_value = static_cast(max_value * max_value); BOOST_CHECK(absolute_value::apply(max_value) >= max_value); BOOST_CHECK(absolute_value::apply(max_value) <= max_value); @@ -95,7 +97,7 @@ struct test_max_values static inline void apply() { Promoted max_value = (std::numeric_limits::max)(); - Promoted max_value_sqr = max_value * max_value; + Promoted max_value_sqr = static_cast(max_value * max_value); BOOST_CHECK(max_value_sqr < (std::numeric_limits::max)() && max_value_sqr > max_value);