This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 19/03/14 23:38 +0100, Paolo Carlini wrote:
On 19/03/14 21:39 +0000, Jonathan Wakely wrote: I think the safe thing to do is (as I suggested at the time) to have a trait saying which iterator types refer to contiguous memory. Our debug mode only supports our own containers, so the ones which are contiguous are known. For 4.9.0 I think the right option is simply to remove __foreign_iterator_aux3 and __foreign_iterator_aux4 completely. The fixed version of __foreign_iterator_aux2() can detect when we have iterators referring to the same sequence, which is what we really want to detect. That's what the attached patch does and what I'm going to test.With my suggested change we get an XPASS for testsuite/23_containers/vector/debug/57779_neg.cc An __is_contiguous trait would solve that.Funny, I thought we already had it...
I think we might have added it and removed it at some point ... not sure though. This is what I plan to commit, it's almost a total rewrite of __foreign_iterator() :-( Dereferencing invalid iterators is avoided by passing in both iterators representing the range, not just the first. The suspect pointer arithmetic that tries to determine if a pointer points inside a container is made unnecessary by adding __gnu_debug::_Is_contiguous_sequence, currently only true for std::vector<T,A> for all T except bool. We don't need to make it true for std::string because that defines _Insert_range_from_self_is_safe instead, so we can never reach the code that depends on contiguous storage. As a benefit of the rewrite it no longer depends on C++11 and so works in C++98 mode. The overload resolution issue is solved by consistently using const-refs for the parameters of __foreign_iterator_aux2. I also added another overload for debug iterators into different debug container types, so they can be identified as foreign sooner, without calling __foreign_iterator_aux3. Everything passes for "make check check-debug", so I plan to commit it tomorrow, unless anyone points out a problem.
Attachment:
patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |