public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Francois Dumont <fdumont@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-9087] libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_wrap behavior Date: Tue, 20 Feb 2024 21:41:20 +0000 (GMT) [thread overview] Message-ID: <20240220214120.9BBED3858D20@sourceware.org> (raw) https://gcc.gnu.org/g:ca5f509903315a56b2f306f8644544861a6525cb commit r14-9087-gca5f509903315a56b2f306f8644544861a6525cb Author: François Dumont <fdumont@gcc.gnu.org> Date: Tue Feb 20 19:24:47 2024 +0100 libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_wrap behavior In _GLIBCXX_DEBUG mode the std::__niter_base can remove 2 layers, the __gnu_debug::_Safe_iterator<> and the __gnu_cxx::__normal_iterator<>. When std::__niter_wrap is called to build a __gnu_debug::_Safe_iterator<> from a __gnu_cxx::__normal_iterator<> we then have a consistency issue as the difference between the 2 iterators will done on a __normal_iterator on one side and a C pointer on the other. To avoid this problem call std::__niter_base on both input iterators. libstdc++-v3/ChangeLog: * include/bits/stl_algobase.h (std::__niter_wrap): Add a call to std::__niter_base on res iterator. Diff: --- libstdc++-v3/include/bits/stl_algobase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 0f73da131729..d534e02871f6 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>
reply other threads:[~2024-02-20 21:41 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=20240220214120.9BBED3858D20@sourceware.org \ --to=fdumont@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: linkBe 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).