explicit casts for -Wconversions warnings in gcc

This commit is contained in:
Lucas Amoudruz 2019-11-27 15:56:05 +01:00
parent fe5460c6dc
commit 78e98c446d

View File

@ -9756,7 +9756,7 @@ PUGI__NS_BEGIN
{ {
xpath_context c(*it, i, size); xpath_context c(*it, i, size);
if (expr->eval_number(c, stack) == i) if (expr->eval_number(c, stack) == static_cast<double>(i))
{ {
*last++ = *it; *last++ = *it;
@ -9780,11 +9780,11 @@ PUGI__NS_BEGIN
double er = expr->eval_number(c, stack); double er = expr->eval_number(c, stack);
if (er >= 1.0 && er <= size) if (er >= 1.0 && er <= static_cast<double>(size))
{ {
size_t eri = static_cast<size_t>(er); size_t eri = static_cast<size_t>(er);
if (er == eri) if (er == static_cast<double>(eri))
{ {
xpath_node r = last[eri - 1]; xpath_node r = last[eri - 1];
@ -10742,7 +10742,7 @@ PUGI__NS_BEGIN
double first = round_nearest(_right->eval_number(c, stack)); double first = round_nearest(_right->eval_number(c, stack));
if (is_nan(first)) return xpath_string(); // NaN if (is_nan(first)) return xpath_string(); // NaN
else if (first >= s_length + 1) return xpath_string(); else if (first >= static_cast<double>(s_length + 1)) return xpath_string();
size_t pos = first < 1 ? 1 : static_cast<size_t>(first); size_t pos = first < 1 ? 1 : static_cast<size_t>(first);
assert(1 <= pos && pos <= s_length + 1); assert(1 <= pos && pos <= s_length + 1);
@ -10766,12 +10766,12 @@ PUGI__NS_BEGIN
double last = first + round_nearest(_right->_next->eval_number(c, stack)); double last = first + round_nearest(_right->_next->eval_number(c, stack));
if (is_nan(first) || is_nan(last)) return xpath_string(); if (is_nan(first) || is_nan(last)) return xpath_string();
else if (first >= s_length + 1) return xpath_string(); else if (first >= static_cast<double>(s_length + 1)) return xpath_string();
else if (first >= last) return xpath_string(); else if (first >= last) return xpath_string();
else if (last < 1) return xpath_string(); else if (last < 1) return xpath_string();
size_t pos = first < 1 ? 1 : static_cast<size_t>(first); size_t pos = first < 1 ? 1 : static_cast<size_t>(first);
size_t end = last >= s_length + 1 ? s_length + 1 : static_cast<size_t>(last); size_t end = last >= static_cast<double>(s_length + 1) ? s_length + 1 : static_cast<size_t>(last);
assert(1 <= pos && pos <= end && end <= s_length + 1); assert(1 <= pos && pos <= end && end <= s_length + 1);
const char_t* rbegin = s.c_str() + (pos - 1); const char_t* rbegin = s.c_str() + (pos - 1);