From: Stephan Bergmann <sberg.fun@gmail.com>
To: libstdc++ <libstdc++@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
"François Dumont" <frs.dumont@gmail.com>,
"Jonathan Wakely" <jwakely@redhat.com>
Subject: Re: [PATCH][_GLIBCXX_DEBUG] Fix std::__niter_base behavior
Date: Mon, 19 Feb 2024 08:07:50 +0100 [thread overview]
Message-ID: <c2db7578-f601-478c-b8bb-63ea28a84090@gmail.com> (raw)
In-Reply-To: <3e1e1652-4320-4b63-a72f-572f045780ca@gmail.com>
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,
> $ cat test.cc
> #include <algorithm>
> #include <vector>
> void f(std::vector<void const *> &v, void const * p) {
> std::erase(v, p);
> }
> $ ~/gcc/inst/bin/g++ -std=c++20 -D_GLIBCXX_DEBUG -fsyntax-only test.cc
> In file included from ~/gcc/inst/include/c++/14.0.1/algorithm:60,
> from test.cc:1:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h: In instantiation of ‘constexpr _From std::__niter_wrap(_From, _To) [with _From = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<const void**, __cxx1998::vector<const void*, allocator<const void*> > >, __debug::vector<const void*>, random_access_iterator_tag>; _To = __gnu_cxx::__normal_iterator<const void**, __cxx1998::vector<const void*, allocator<const void*> > >]’:
> ~/gcc/inst/include/c++/14.0.1/vector:144:29: required from ‘constexpr typename std::__debug::vector<_Tp, _Allocator>::size_type std::erase(__debug::vector<_Tp, _Alloc>&, const _Up&) [with _Tp = const void*; _Alloc = allocator<const void*>; _Up = const void*; typename __debug::vector<_Tp, _Allocator>::size_type = long unsigned int]’
> 144 | __cont.erase(__niter_wrap(__cont.begin(), __removed),
> | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> test.cc:4:15: required from here
> 4 | std::erase(v, p);
> | ~~~~~~~~~~^~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: error: no match for ‘operator-’ (operand types are ‘__gnu_cxx::__normal_iterator<const void**, std::__cxx1998::vector<const void*, std::allocator<const void*> > >’ and ‘const void**’)
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:67:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1148:7: note: candidate: ‘constexpr __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(difference_type) const [with _Iterator = const void**; _Container = std::__cxx1998::vector<const void*, std::allocator<const void*> >; difference_type = long int]’ (near match)
> 1148 | operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
> | ^~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1148:7: note: conversion of argument 1 would be ill-formed:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:49: error: invalid conversion from ‘const void**’ to ‘__gnu_cxx::__normal_iterator<const void**, std::__cxx1998::vector<const void*, std::allocator<const void*> > >::difference_type’ {aka ‘long int’} [-fpermissive]
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~~~~~~~~~~~^~~~~~~~
> | |
> | const void**
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:618:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorR>&)’
> 618 | operator-(const reverse_iterator<_IteratorL>& __x,
> | ^~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note: ‘__gnu_cxx::__normal_iterator<const void**, std::__cxx1998::vector<const void*, std::allocator<const void*> > >’ is not derived from ‘const std::reverse_iterator<_IteratorL>’
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1789:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
> 1789 | operator-(const move_iterator<_IteratorL>& __x,
> | ^~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1789:5: note: template argument deduction/substitution failed:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note: ‘__gnu_cxx::__normal_iterator<const void**, std::__cxx1998::vector<const void*, std::allocator<const void*> > >’ is not derived from ‘const std::move_iterator<_IteratorL>’
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1312:5: note: candidate: ‘template<class _IteratorL, class _IteratorR, class _Container> constexpr decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)’
> 1312 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
> | ^~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1312:5: note: template argument deduction/substitution failed:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note: mismatched types ‘const __gnu_cxx::__normal_iterator<_IteratorR, _Container>’ and ‘const void**’
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1325:5: note: candidate: ‘template<class _Iterator, class _Container> constexpr typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)’
> 1325 | operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
> | ^~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_iterator.h:1325:5: note: template argument deduction/substitution failed:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:347:30: note: mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘const void**’
> 347 | { return __from + (__res - std::__niter_base(__from)); }
> | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
next prev parent reply other threads:[~2024-02-19 7:07 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 [this message]
2024-02-19 8:12 ` Jonathan Wakely
2024-02-19 8:21 ` Jonathan Wakely
2024-02-19 18:39 ` François Dumont
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=c2db7578-f601-478c-b8bb-63ea28a84090@gmail.com \
--to=sberg.fun@gmail.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--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).