Correct logic bug in find optimization for vector<bool>. This fixes http://llvm.org/bugs/show_bug.cgi?id=16816
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187908 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__bit_reference b/include/__bit_reference
index 8ff3bf6..58d475e 100644
--- a/include/__bit_reference
+++ b/include/__bit_reference
@@ -173,6 +173,8 @@
__storage_type __b = *__first.__seg_ & __m;
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ if (__n == __dn)
+ return _It(__first.__seg_, __first.__ctz_ + __n);
__n -= __dn;
++__first.__seg_;
}
@@ -207,6 +209,8 @@
__storage_type __b = ~*__first.__seg_ & __m;
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ if (__n == __dn)
+ return _It(__first.__seg_, __first.__ctz_ + __n);
__n -= __dn;
++__first.__seg_;
}