Avoid -Wsign-compare warnings in std::to_string()

* include/ext/string_conversions.h (__stoa): Avoid -Wsign-compare
        warnings.

From-SVN: r235151
This commit is contained in:
Jonathan Wakely 2016-04-18 16:43:50 +01:00 committed by Jonathan Wakely
parent 8270b82dd6
commit 8dc1e574ae
2 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2016-04-18 Jonathan Wakely <jwakely@redhat.com>
* include/ext/string_conversions.h (__stoa): Avoid -Wsign-compare
warnings.
2016-04-17 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/bits/specfun.h: Trivial comment misspelling.

View File

@ -65,14 +65,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int _M_errno;
} const __save_errno;
struct _Range_chk {
static bool
_S_chk(_TRet, std::false_type) { return false; }
static bool
_S_chk(_TRet __val, std::true_type) // only called when _Ret is int
{
return __val < _TRet(__numeric_traits<int>::__min)
|| __val > _TRet(__numeric_traits<int>::__max);
}
};
const _TRet __tmp = __convf(__str, &__endptr, __base...);
if (__endptr == __str)
std::__throw_invalid_argument(__name);
else if (errno == ERANGE
|| (std::__are_same<_Ret, int>::__value
&& (__tmp < __numeric_traits<int>::__min
|| __tmp > __numeric_traits<int>::__max)))
|| _Range_chk::_S_chk(__tmp, std::is_same<_Ret, int>{}))
std::__throw_out_of_range(__name);
else
__ret = __tmp;