diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c89020ef029..24fc5ae6486 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2017-01-24 Jonathan Wakely + + PR libstdc++/79206 + * include/experimental/string_view (operator==): Check sizes first. + * include/std/string_view (operator==): Likewise. + 2017-01-23 Jonathan Wakely * testsuite/experimental/array/make_array.cc: Restore diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index eaff0cc764c..2a2364cfa1e 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -456,19 +456,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(basic_string_view<_CharT, _Traits> __x, __detail::__idt> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(__detail::__idt> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 9eee528102c..a71918553bb 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -453,19 +453,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(basic_string_view<_CharT, _Traits> __x, __detail::__idt> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(__detail::__idt> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool