|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82695 - in trunk: boost libs/conversion libs/conversion/test
From: antoshkka_at_[hidden]
Date: 2013-02-06 20:24:20
Author: apolukhin
Date: 2013-02-03 04:20:28 EST (Sun, 03 Feb 2013)
New Revision: 82695
URL: http://svn.boost.org/trac/boost/changeset/82695
Log:
Fixed as many -Wconversion warnings in lexical cast and tests as possible (refs #2558)
Text files modified:
trunk/boost/lexical_cast.hpp | 30 +++++++++++++++---------------
trunk/libs/conversion/numeric_cast_test.cpp | 2 +-
trunk/libs/conversion/test/lexical_cast_vc8_bug_test.cpp | 4 ++--
3 files changed, 18 insertions(+), 18 deletions(-)
Modified: trunk/boost/lexical_cast.hpp
==============================================================================
--- trunk/boost/lexical_cast.hpp (original)
+++ trunk/boost/lexical_cast.hpp 2013-02-03 04:20:28 EST (Sun, 03 Feb 2013)
@@ -838,7 +838,7 @@
if(group < grouping_size)
{
char const grp_size = grouping[group];
- last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size;
+ last_grp_size = grp_size <= 0 ? static_cast<char>(CHAR_MAX) : grp_size;
}
left = last_grp_size;
@@ -886,7 +886,7 @@
if (begin > end || *end < czero || *end >= czero + 10)
return false;
- value = *end - czero;
+ value = static_cast<T>(*end - czero);
--end;
T multiplier = 1;
bool multiplier_overflowed = false;
@@ -906,17 +906,17 @@
{
unsigned char current_grouping = 0;
CharT const thousands_sep = np.thousands_sep();
- char remained = grouping[current_grouping] - 1;
+ char remained = static_cast<char>(grouping[current_grouping] - 1);
bool shall_we_return = true;
for(;end>=begin; --end)
{
if (remained) {
- T const multiplier_10 = multiplier * 10;
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
- T const dig_value = *end - czero;
- T const new_sub_value = multiplier_10 * dig_value;
+ T const dig_value = static_cast<T>(*end - czero);
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
if (*end < czero || *end >= czero + 10
/* detecting overflow */
@@ -926,8 +926,8 @@
)
return false;
- value += new_sub_value;
- multiplier *= 10;
+ value = static_cast<T>(value + new_sub_value);
+ multiplier = static_cast<T>(multiplier * 10);
--remained;
} else {
if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false;
@@ -960,11 +960,11 @@
{
while ( begin <= end )
{
- T const multiplier_10 = multiplier * 10;
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
- T const dig_value = *end - czero;
- T const new_sub_value = multiplier_10 * dig_value;
+ T const dig_value = static_cast<T>(*end - czero);
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
if (*end < czero || *end >= czero + 10
/* detecting overflow */
@@ -974,8 +974,8 @@
)
return false;
- value += new_sub_value;
- multiplier *= 10;
+ value = static_cast<T>(value + new_sub_value);
+ multiplier = static_cast<T>(multiplier * 10);
--end;
}
}
@@ -1192,7 +1192,7 @@
: np.grouping()
);
std::string::size_type const grouping_size = grouping.size();
- CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0;
+ CharT const thousands_sep = static_cast<CharT>(grouping_size ? np.thousands_sep() : 0);
CharT const decimal_point = np.decimal_point();
bool found_grouping = false;
std::string::size_type last_grouping_pos = grouping_size - 1;
@@ -2350,7 +2350,7 @@
> converter_t;
return (
- arg < 0 ? 0u - converter_t::convert(0u - arg) : converter_t::convert(arg)
+ arg < 0 ? static_cast<Target>(0u - converter_t::convert(0u - arg)) : converter_t::convert(arg)
);
}
};
Modified: trunk/libs/conversion/numeric_cast_test.cpp
==============================================================================
--- trunk/libs/conversion/numeric_cast_test.cpp (original)
+++ trunk/libs/conversion/numeric_cast_test.cpp 2013-02-03 04:20:28 EST (Sun, 03 Feb 2013)
@@ -48,7 +48,7 @@
long large_negative_value = LONG_MIN;
signed char c = 0;
- c = large_value; // see if compiler generates warning
+ c = static_cast<signed char>(large_value);
c = numeric_cast<signed char>( small_value );
BOOST_CHECK( c == 1 );
Modified: trunk/libs/conversion/test/lexical_cast_vc8_bug_test.cpp
==============================================================================
--- trunk/libs/conversion/test/lexical_cast_vc8_bug_test.cpp (original)
+++ trunk/libs/conversion/test/lexical_cast_vc8_bug_test.cpp 2013-02-03 04:20:28 EST (Sun, 03 Feb 2013)
@@ -34,7 +34,7 @@
o << (limits::max)() << zero;
s = o.str();
BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
- s[s.size()-1] += 9; // '0' -> '9'
+ s[s.size()-1] += static_cast<CharT>(9); // '0' -> '9'
BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
if(limits::is_signed)
@@ -43,7 +43,7 @@
o << (limits::min)() << zero;
s = o.str();
BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
- s[s.size()-1] += 9; // '0' -> '9'
+ s[s.size()-1] += static_cast<CharT>(9); // '0' -> '9'
BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
}
}
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