[libcxx-commits] [libcxx] [regex] fix uncaught exception when string is like "\\_" (PR #129348)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 10 02:23:42 PDT 2025
================
@@ -669,6 +671,21 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::cmatch m;
+ const char s[] = "$_se";
+ assert(std::regex_match(s, m, std::regex("\\$\\_se")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) >= 0 && static_cast<size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
----------------
frederick-vs-ja wrote:
This part seems lost when adding coverage for `wchar_t`. We should test both `char` and `wchar_t` cases.
https://github.com/llvm/llvm-project/pull/129348
More information about the libcxx-commits
mailing list