This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: unsafe STL patch


I solved my problem, indeed it was coming from pch. I have regenerated them now and it works fine, I will complete the patch.

About the limitation to random access iterator. It has to be so to keep on detecting this kind of problem:

using namespace std;
list<int> l({1, 2, 3});
vector<int> v;

list<int>::iterator first(l.begin()), last(l.begin());
++first; ++first;
++last;
v.insert(v.end(), first, last);

You see range iterator is badly defined because first is after last. This is something that cannot be detected by the check_range function because there is no < operator on bidirectional iterator. The problem will only appear when we will reach past the list end when incrementing first if first is still a _Safe_Iterator.

I have also 2 questions for my patch:
1. debug functions are taking _Safe_Iterator by const reference. __iter_base::__b takes it by value, do you think it should be better by const reference ?
2. I read a comment about taking care of iterator type that might be derived from the _Safe_Iterator type. Do you think that we shouldn't extract the base if we are on such a derived type ?


Bests

Paolo Carlini wrote:

... ah yes, I have in mind a more specific comment, about your general
idea: I'm not sure to understand why you are calling .base() only for
random access iterators: as far as I can see, assuming you have a
_Safe_iterator, that's always the correct thing to do...

Paolo.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]