]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/79206 check string_view sizes in operator==
authorJonathan Wakely <jwakely@redhat.com>
Tue, 24 Jan 2017 12:00:47 +0000 (12:00 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 24 Jan 2017 12:00:47 +0000 (12:00 +0000)
PR libstdc++/79206
* include/experimental/string_view (operator==): Check sizes first.
* include/std/string_view (operator==): Likewise.

From-SVN: r244865

libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/string_view
libstdc++-v3/include/std/string_view

index c89020ef029d533a18eb937d458bdb9fc816a8de..24fc5ae64860c0a918f56660cf1e14eca4ddde25 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-24  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/79206
+       * include/experimental/string_view (operator==): Check sizes first.
+       * include/std/string_view (operator==): Likewise.
+
 2017-01-23  Jonathan Wakely  <jwakely@redhat.com>
 
        * testsuite/experimental/array/make_array.cc: Restore <functional>
index eaff0cc764c21bf80f487a92d0e8ca0e485b82b1..2a2364cfa1e88f29625c7238284ff2dc4d0deaf2 100644 (file)
@@ -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<typename _CharT, typename _Traits>
     inline bool
     operator==(basic_string_view<_CharT, _Traits> __x,
                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) == 0; }
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
 
   template<typename _CharT, typename _Traits>
     inline bool
     operator==(__detail::__idt<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<typename _CharT, typename _Traits>
     inline bool
index 9eee528102c53d2a70290f27c48fccf3d5d493e8..a71918553bb5f7c73285269bbbc57295940d0b83 100644 (file)
@@ -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<typename _CharT, typename _Traits>
     inline bool
     operator==(basic_string_view<_CharT, _Traits> __x,
                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) == 0; }
+    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
 
   template<typename _CharT, typename _Traits>
     inline bool
     operator==(__detail::__idt<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<typename _CharT, typename _Traits>
     inline bool