Fix PR 19663. Some calls to find(vector<bool>) were returning iterators that were subtly invalid (didn't compare equal). Thanks to Erik Verbruggen for the report (and diagnosis)

llvm-svn: 208096
This commit is contained in:
Marshall Clow 2014-05-06 15:33:23 +00:00
parent 8fbbfbbec3
commit 0fc6e981b0
2 changed files with 4 additions and 2 deletions

View File

@ -174,7 +174,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
if (__n == __dn)
return _It(__first.__seg_, __first.__ctz_ + __n);
return __first + __n;
__n -= __dn;
++__first.__seg_;
}
@ -210,7 +210,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
if (__n == __dn)
return _It(__first.__seg_, __first.__ctz_ + __n);
return __first + __n;
__n -= __dn;
++__first.__seg_;
}

View File

@ -25,6 +25,7 @@ int main()
std::vector<bool> b(i,true);
std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
assert(j-b.begin() == i);
assert(b.end() == j);
}
}
{
@ -33,6 +34,7 @@ int main()
std::vector<bool> b(i,false);
std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
assert(j-b.begin() == i);
assert(b.end() == j);
}
}
}