On 21/08/18 22:18 +0200, François Dumont wrote:
On 21/08/2018 11:33, Jonathan Wakely wrote:
On 18/08/18 22:31 +0200, François Dumont wrote:
Here is the new proposal. It is indeed possible to keep
_Safe_iterator and just add a _Category template parameter to
it.
While this is still a large patch (obviously, because it's changing a
lot!) I think this version is much easier to understand, and doesn't
add a whole new class unnecessarily. Thanks for updating it.
I introduce a friend declaration to access container _Base
nested typedef from the safe iterator.
I review the safe const_iterator constructor from safe
iterator. I now check if we are in the a const_iterator
context so that compilers don't even try to consider this
constructor when we are in an iterator context.
Nice.
I adapted _Safe_local_iterator the same way to keep
consistency with _Safe_iterator and because I find the new
design cleaner. It also fixes the same problem I fixed on
_Safe_iterator when checking it iterator has been initialized
using _MutableIterator() rather than _Iterator().
I stop overloading __get_distance for safe iterators or safe
local iterators, it was useless. I prefer to introduce similar
functions as members. Same for __get_distance_from_begin or
__get_distance_to_end, and I move code in safe_iterator.tcc.
Tested under Linux x86_64 debug mode.
Ok to commit ?
OK for trunk, thanks again.
Note that it also avoids to adapt the pretty printers scripts.
I'll commit it tomorrow once I'll have rework the ChangeLog entry.
I'll also add the test case in PR 68222 adapted for the testsuite.
I'm not sure when it started, but I'm seeing a few failures in the
testsuite, with linker errors like this:
FAIL: 25_algorithms/sort/34636.cc (test for excess errors)
Excess errors:
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:614: undefined reference to `std::__debug::vector<int, std::allocator<int> >* std::__niter_base<std::__debug::vector<int, std::allocator<int> >*,
std::__cxx1998::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >,
std::allocator<std::__debug::vector<int, std::allocator<int> > > > >(__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::__debug::vector<int, std::allocator<int> >*, std::__cxx1998::vector<std::__debug::vector<int,
std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int,
std::allocator<int> > > >, std::random_access_iterator_tag> const&)'
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:614: undefined reference to `std::__debug::vector<int, std::allocator<int> >* std::__niter_base<std::__debug::vector<int, std::allocator<int> >*,
std::__cxx1998::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >,
std::allocator<std::__debug::vector<int, std::allocator<int> > > > >(__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::__debug::vector<int, std::allocator<int> >*, std::__cxx1998::vector<std::__debug::vector<int,
std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int,
std::allocator<int> > > >, std::random_access_iterator_tag> const&)'
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:614: undefined reference to `std::__debug::vector<int, std::allocator<int> >* std::__niter_base<std::__debug::vector<int, std::allocator<int> >*,
std::__cxx1998::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >,
std::allocator<std::__debug::vector<int, std::allocator<int> > > > >(__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::__debug::vector<int, std::allocator<int> >*, std::__cxx1998::vector<std::__debug::vector<int,
std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int,
std::allocator<int> > > >, std::random_access_iterator_tag> const&)'
/home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:286: undefined reference to `std::__debug::vector<int, std::allocator<int> >* std::__niter_base<std::__debug::vector<int, std::allocator<int> >*,
std::__cxx1998::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >,
std::allocator<std::__debug::vector<int, std::allocator<int> > > > >(__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::__debug::vector<int, std::allocator<int> >*, std::__cxx1998::vector<std::__debug::vector<int,
std::allocator<int> >, std::allocator<std::__debug::vector<int, std::allocator<int> > > > >, std::__debug::vector<std::__debug::vector<int, std::allocator<int> >, std::allocator<std::__debug::vector<int,
std::allocator<int> > > >, std::random_access_iterator_tag> const&)'
collect2: error: ld returned 1 exit status
This happens when run like:
make check RUNTESTFLAGS="conformance.exp==25_algorithms/sort/*.cc
--target_board=unix/-std=gnu++98/-D_GLIBCXX_USE_CXX11_ABI=0/-D_GLIBCXX_DEBUG"