Fix a bug in regex_Iterator where it would report zero-length matches forever. Reported as http://llvm.org/PR33681. Thanks to Karen Arutyunov for the report.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307171 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2017-07-05 16:37:19 +00:00
parent 530ad8eb20
commit e00d350bbd
2 changed files with 19 additions and 1 deletions

View File

@@ -95,4 +95,22 @@ int main()
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
}
{ // http://llvm.org/PR33681
std::regex rex(".*");
const char foo[] = "foo";
// The -1 is because we don't want the implicit null from the array.
std::cregex_iterator i(std::begin(foo), std::end(foo) - 1, rex);
std::cregex_iterator e;
assert(i != e);
assert((*i).size() == 1);
assert((*i).str() == "foo");
++i;
assert(i != e);
assert((*i).size() == 1);
assert((*i).str() == "");
++i;
assert(i == e);
}
}