From: "François Dumont" <frs.dumont@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>,
Stephan Bergmann <sberg.fun@gmail.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>,
Jonathan Wakely <jwakely@redhat.com>
Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior
Date: Mon, 19 Feb 2024 19:39:17 +0100 [thread overview]
Message-ID: <1ac67b3d-6c13-4b23-994d-2a0ef396b297@gmail.com> (raw)
In-Reply-To: <CAH6eHdTzZi6goUqM7QNjZAsYc1EvowbsV=c9qwKMkMf2tdTWqA@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1524 bytes --]
Turns out that 23_containers/vector/erasure.cc was showing the problem
in _GLIBCXX_DEBUG mode.
I had only run 25_algorithms tests in _GLIBCXX_DEBUG mode.
This is what I'm testing, I 'll let you know tomorrow morning if all
successful.
Of course feel free to do or ask for a revert instead.
François
On 19/02/2024 09:21, Jonathan Wakely wrote:
>
>
> On Mon, 19 Feb 2024, 08:12 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:
>
>
>
> On Mon, 19 Feb 2024, 07:08 Stephan Bergmann, <sberg.fun@gmail.com>
> wrote:
>
> On 2/17/24 15:14, François Dumont wrote:
> > Thanks for the link, tested and committed.
>
> I assume this is the cause for the below failure now,
>
>
> Yes, the new >= C++11 overload of __niter_base recursively unwraps
> multiple layers of wrapping, so that a safe iterator wrapping a
> normal iterator wrapping a pointer is unwrapped to just a pointer.
> But then __niter_wrap doesn't restore both layers.
>
>
>
> Actually that's not the problem. __niter_wrap would restore both
> layers, except that it uses __niter_base itself:
>
> > 347 | { return __from + (__res - std::__niter_base(__from)); }
> > | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> And it seems to be getting called with the wrong types. Maybe that's
> just a bug in std:: erase or maybe niter_wrap needs adjusting.
>
> I'll check in a couple of hours if François doesn't get to it first.
>
> I have to wonder how this wasn't caught by existing tests though.
>
>
>
[-- Attachment #2: niter_wrap_patch.txt --]
[-- Type: text/plain, Size: 606 bytes --]
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 0f73da13172..d534e02871f 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -344,7 +344,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX20_CONSTEXPR
inline _From
__niter_wrap(_From __from, _To __res)
- { return __from + (__res - std::__niter_base(__from)); }
+ { return __from + (std::__niter_base(__res) - std::__niter_base(__from)); }
// No need to wrap, iterator already has the right type.
template<typename _Iterator>
next prev parent reply other threads:[~2024-02-19 18:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 18:39 François Dumont
2024-02-14 19:44 ` Jonathan Wakely
2024-02-14 21:48 ` François Dumont
2024-02-15 13:17 ` Jonathan Wakely
2024-02-15 18:38 ` François Dumont
2024-02-15 18:40 ` Jonathan Wakely
2024-02-17 14:14 ` François Dumont
2024-02-19 7:07 ` Stephan Bergmann
2024-02-19 8:12 ` Jonathan Wakely
2024-02-19 8:21 ` Jonathan Wakely
2024-02-19 18:39 ` François Dumont [this message]
2024-02-20 18:42 ` François Dumont
2024-02-20 19:27 ` Jonathan Wakely
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=1ac67b3d-6c13-4b23-994d-2a0ef396b297@gmail.com \
--to=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=sberg.fun@gmail.com \
/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).