From 352bd3a273848a19e10882c61bee06895b63deb0 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 31 Dec 2012 20:09:48 +0000 Subject: [PATCH] Klaas de Vries: Fix bug in libc++'s std::string::find_first_not_of. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@171321 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/string | 2 +- .../string.ops/string_find.first.not.of/char_size.pass.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/string b/include/string index 5bf42f02..1a704679 100644 --- a/include/string +++ b/include/string @@ -3374,7 +3374,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, { const_pointer __p = data(); const_pointer __pe = __p + __sz; - for (const_pointer __ps = __p + __pos; __p != __pe; ++__ps) + for (const_pointer __ps = __p + __pos; __ps != __pe; ++__ps) if (!traits_type::eq(*__ps, __c)) return static_cast(__ps - __p); } diff --git a/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp b/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp index 88ce6b98..3be9e92d 100644 --- a/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp +++ b/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp @@ -59,6 +59,8 @@ int main() test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos); test(S(""), 'q', S::npos); + test(S("q"), 'q', S::npos); + test(S("qqq"), 'q', S::npos); test(S("csope"), 'q', 0); test(S("gfsmthlkon"), 'q', 0); test(S("laenfsbridchgotmkqpj"), 'q', 0);