]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: avoid bogus -Wrestrict [PR105651]
authorJason Merrill <jason@redhat.com>
Fri, 19 Aug 2022 03:53:16 +0000 (23:53 -0400)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 21 Jun 2023 09:09:41 +0000 (10:09 +0100)
PR tree-optimization/105651

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (_M_replace): Add an assert
to avoid -Wrestrict false positive.

libstdc++-v3/include/bits/basic_string.tcc

index 0696b96604c168111ae16aa66e245d83d7578c87..48fa28e64668248c8e28584efed71fd051537154 100644 (file)
@@ -529,6 +529,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                    {
                      const size_type __nleft = (__p + __len1) - __s;
                      this->_S_move(__p, __s, __nleft);
+                     // Tell the middle-end that the copy can't overlap
+                     // (PR105651).
+                     if (__len2 < __nleft)
+                       __builtin_unreachable();
                      this->_S_copy(__p + __nleft, __p + __len2,
                                    __len2 - __nleft);
                    }