public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-9716] libstdc++: avoid bogus -Wrestrict [PR105651]
Date: Wed, 21 Jun 2023 12:18:54 +0000 (GMT)	[thread overview]
Message-ID: <20230621121854.67BE83858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:636795a6dfc17ead7b22b9f76b0fc47bdb9d357d

commit r12-9716-g636795a6dfc17ead7b22b9f76b0fc47bdb9d357d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 18 23:53:16 2022 -0400

    libstdc++: avoid bogus -Wrestrict [PR105651]
    
            PR tree-optimization/105651
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/basic_string.tcc (_M_replace): Add an assert
            to avoid -Wrestrict false positive.

Diff:
---
 libstdc++-v3/include/bits/basic_string.tcc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 0696b96604c..48fa28e6466 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -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);
 		    }

                 reply	other threads:[~2023-06-21 12:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230621121854.67BE83858D28@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).