public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Bug libstdc++/99402] [10 Regression] std::copy creates _GLIBCXX_DEBUG false positive for attempt to subscript a dereferenceable (start-of-sequence) iterator
Date: Sun, 18 Apr 2021 15:04:12 +0100	[thread overview]
Message-ID: <CAH6eHdSJx=Rq=T65HDw_MoRBmv4zc2stDwg4jRM4T11pXwH+kw@mail.gmail.com> (raw)
In-Reply-To: <70f13ddf-8b3a-1a6b-006f-21a9cb3a5db9@gmail.com>

On Sun, 18 Apr 2021, 15:01 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> Hi
>
>      Ok to backport this to gcc-10 branch ?
>


Yes please, thanks.



>      Tested under Linux x86_64.
>
> François
>
>
> On 13/04/21 10:51 pm, redi at gcc dot gnu.org wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99402
> >
> > Jonathan Wakely <redi at gcc dot gnu.org> changed:
> >
> >             What    |Removed                     |Added
> >
> ----------------------------------------------------------------------------
> >              Summary|[10/11 Regression]          |[10 Regression]
> std::copy
> >                     |std::copy creates           |creates _GLIBCXX_DEBUG
> >                     |_GLIBCXX_DEBUG false        |false positive for
> attempt
> >                     |positive for attempt to     |to subscript a
> >                     |subscript a dereferenceable |dereferenceable
> >                     |(start-of-sequence)         |(start-of-sequence)
> >                     |iterator                    |iterator
> >
> > --- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> > This was fixed on trunk by r11-8100:
> >
> > libstdc++: [_GLIBCXX_DEBUG] Fix management of __dp_sign_max_size [PR
> 99402]
> >
> > __dp_sign precision indicates that we found out what iterator comes
> first or
> > last in the range. __dp_sign_max_size is the same plus it gives the
> information
> > of the max size of the range that is to say the max_size value such that
> > distance(lhs, rhs) < max_size.
> > Thanks to this additional information we are able to tell when a copy of
> n
> > elements
> > to that range will fail even if we do not know exactly how large it is.
> >
> > This patch makes sure that we are properly using this information.
> >
> > libstdc++-v3/ChangeLog:
> >
> >          PR libstdc++/99402
> >          * include/debug/helper_functions.h
> (__can_advance(_InputIterator,
> >          const std::pair<_Diff, _Distance_precision>&, int)): New.
> >          (__can_advance(const _Safe_iterator<>&,
> >          const std::pair<_Diff, _Distance_precision>&, int)): New.
> >          * include/debug/macros.h (__glibcxx_check_can_increment_dist):
> New,
> >          use latter.
> >          (__glibcxx_check_can_increment_range): Adapt to use latter.
> >          (__glibcxx_check_can_decrement_range): Likewise.
> >          * include/debug/safe_iterator.h
> >          (_Safe_iterator<>::_M_can_advance(const std::pair<_Diff,
> > _Distance_precision>&,
> >          int)): New.
> >          (__can_advance(const _Safe_iterator<>&,
> >          const std::pair<_Diff, _Distance_precision>&, int)): New.
> >          * include/debug/safe_iterator.tcc
> >          (_Safe_iterator<>::_M_can_advance(const std::pair<_Diff,
> > _Distance_precision>&,
> >          int)): New.
> >          (_Safe_iterator<>::_M_valid_range(const _Safe_iterator<>&,
> >          std::pair<difference_type, _Distance_precision>&, bool)): Adapt
> for
> >          __dp_sign_max_size.
> >          (__copy_move_a): Adapt to use
> __glibcxx_check_can_increment_dist.
> >          (__copy_move_backward_a): Likewise.
> >          (__equal_aux): Likewise.
> >          * include/debug/stl_iterator.h (__can_advance(const
> > std::reverse_iterator<>&,
> >          const std::pair<_Diff, _Distance_precision>&, int)): New.
> >          (__can_advance(const std::move_iterator<>&,
> >          const std::pair<_Diff, _Distance_precision>&, int)): New.
> >          * testsuite/25_algorithms/copy/debug/99402.cc: New test.
> >
>
>

      reply	other threads:[~2021-04-18 14:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-99402-19885@http.gcc.gnu.org/bugzilla/>
     [not found] ` <bug-99402-19885-WRC4AU1Dpn@http.gcc.gnu.org/bugzilla/>
2021-03-07 21:30   ` [Bug libstdc++/99402] [10/11 " François Dumont
2021-03-11 17:51     ` François Dumont
2021-04-08 13:07       ` Jonathan Wakely
2021-04-09 20:02         ` François Dumont
     [not found] ` <bug-99402-19885-PxIZ3sL1KH@http.gcc.gnu.org/bugzilla/>
2021-04-18 13:28   ` [Bug libstdc++/99402] [10 " François Dumont
2021-04-18 14:04     ` Jonathan Wakely [this message]

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='CAH6eHdSJx=Rq=T65HDw_MoRBmv4zc2stDwg4jRM4T11pXwH+kw@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@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).