public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/99402] [10/11 Regression] std::copy creates _GLIBCXX_DEBUG false positive for attempt to subscript a dereferenceable (start-of-sequence) iterator
Date: Fri, 05 Mar 2021 12:55:58 +0000	[thread overview]
Message-ID: <bug-99402-4-fhoPxubdhT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99402-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99402

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> You should be using __base_dist.second, no?

No, it's not that simple. I don't understand how this code is meant to work,
but this can't be right:

      if (this->_M_is_begin())
        {
          if (__rhs._M_is_before_begin())
            return std::make_pair(-1, __dp_exact);

          if (__rhs._M_is_end())
            return __seq_dist;

          return std::make_pair(__seq_dist.first,
                                __seq_dist.second == __dp_exact
                                ? __dp_sign_max_size : __seq_dist.second);
        }

We can't use __seq_dist.first as the distance, because we have already
established that __rhs is not the end iterator, so it must be before the end.
And so the distance we're trying to find must be less than __seq_dist.first.

  parent reply	other threads:[~2021-03-05 12:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  9:09 [Bug c++/99402] New: " kip at thevertigo dot com
2021-03-05 12:16 ` [Bug libstdc++/99402] [10/11 Regression] " redi at gcc dot gnu.org
2021-03-05 12:30 ` redi at gcc dot gnu.org
2021-03-05 12:33 ` redi at gcc dot gnu.org
2021-03-05 12:40 ` redi at gcc dot gnu.org
2021-03-05 12:55 ` redi at gcc dot gnu.org [this message]
2021-03-05 12:59 ` redi at gcc dot gnu.org
2021-03-05 19:26 ` fdumont at gcc dot gnu.org
2021-03-05 20:00 ` kip at thevertigo dot com
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-04-08 12:53 ` rguenth at gcc dot gnu.org
2021-04-13 20:51 ` [Bug libstdc++/99402] [10 " redi at gcc dot gnu.org
2021-04-13 22:19 ` kip at thevertigo dot com
2021-04-13 22:45 ` redi at gcc dot gnu.org
2021-04-23 12:02 ` fdumont at gcc dot gnu.org
2021-04-23 13:04 ` redi at gcc dot gnu.org

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=bug-99402-4-fhoPxubdhT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).