This is the mail archive of the
mailing list for the libstdc++ project.
Re: Improve insert/emplace robustness to self insertion
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 29 Jun 2016 22:54:58 +0100
- Subject: Re: Improve insert/emplace robustness to self insertion
- Authentication-results: sourceware.org; auth=none
- References: <20160615101511 dot GN11538 at redhat dot com> <20160615103424 dot GO11538 at redhat dot com> <5762FDAC dot 5000802 at gmail dot com> <20160616202106 dot GB11538 at redhat dot com> <57665607 dot 7080004 at gmail dot com> <20160620074230 dot GB6159 at redhat dot com> <5772D70D dot 4020103 at gmail dot com> <20160629091056 dot GH7722 at redhat dot com> <577424D3 dot 10008 at gmail dot com>
On 29/06/16 21:43 +0200, François Dumont wrote:
I tried those changes too but started having failing tests in
vector/ext_pointer so prefer to not touch that for the moment. I think
the compilation error was coming from the change of begin() +
(__position - cbegin()) into begin() + __n because of overloaded
operator+. The 2 other changes should be fine for a future patch.
By the way, I fixed that in my patch too. The problem was that __n had
type size_type, but for adding to iterators it should really be
difference_type. Simply using auto makes it work :-)
Unless you see any problems in my patch I'll finish testing it
tomorrow and commit it with your new testcases.
Thanks for inspiring me to investigate what we were doing wrong! :-)