Skip to content

Commit 923cc58

Browse files
committed
[regex] fix uncaught exception when string is like "\\_"
fixes #129062
1 parent a955426 commit 923cc58

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

libcxx/include/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
39543954
++__first;
39553955
break;
39563956
default:
3957-
if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) {
3957+
if (!__traits_.isctype(*__first, ctype_base::alnum)) {
39583958
if (__str)
39593959
*__str = *__first;
39603960
else

libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,21 @@ test(const CharT* p, unsigned mc)
2525
assert(r.mark_count() == mc);
2626
}
2727

28+
template <class CharT>
29+
void
30+
test1(const CharT* p, const CharT * testString)
31+
{
32+
std::regex regexObj(p);
33+
assert(std::regex_match(testString, regexObj));
34+
}
35+
2836
int main(int, char**)
2937
{
3038
test("\\(a\\)", 0);
3139
test("\\(a[bc]\\)", 0);
3240
test("\\(a\\([bc]\\)\\)", 0);
3341
test("(a([bc]))", 2);
42+
test1("\\$\\_se", "$_se");
3443

35-
return 0;
44+
return 0;
3645
}

0 commit comments

Comments
 (0)