2017-12-01 Jonathan Wakely <jwakely@redhat.com>
+ * include/experimental/string_view (basic_string_view::_S_compare):
+ Use value-init so narrowing conversions are not ill-formed.
+ * include/std/string_view (basic_string_view::_S_compare): Likewise.
+
* include/bits/basic_string.h (operator""s): Add pragmas to disable
-Wliteral-suffix warnings.
* include/experimental/string_view (operator""sv): Likewise.
static constexpr int
_S_compare(size_type __n1, size_type __n2) noexcept
{
- return difference_type{__n1 - __n2} > std::numeric_limits<int>::max()
+ return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
? std::numeric_limits<int>::max()
- : difference_type{__n1 - __n2} < std::numeric_limits<int>::min()
+ : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
? std::numeric_limits<int>::min()
- : static_cast<int>(difference_type{__n1 - __n2});
+ : static_cast<int>(difference_type(__n1 - __n2));
}
size_t _M_len;
static constexpr int
_S_compare(size_type __n1, size_type __n2) noexcept
{
- const difference_type __diff{__n1 - __n2};
+ const difference_type __diff = __n1 - __n2;
if (__diff > std::numeric_limits<int>::max())
return std::numeric_limits<int>::max();
if (__diff < std::numeric_limits<int>::min())