diff --git a/stl/inc/regex b/stl/inc/regex index adc8749ad35..d688a526e30 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -3521,7 +3521,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Find_first_inner_capture case _N_assert: case _N_neg_assert: - if (_Find_first_inner_capture_group(static_cast<_Node_assert*>(_Nx), _Loop_state)) { + if (_Find_first_inner_capture_group(static_cast<_Node_assert*>(_Nx)->_Child, _Loop_state)) { _Found_group = true; _Nx = nullptr; } diff --git a/tests/std/tests/VSO_0000000_regex_use/test.cpp b/tests/std/tests/VSO_0000000_regex_use/test.cpp index 90fe42f4c39..b779b4f051d 100644 --- a/tests/std/tests/VSO_0000000_regex_use/test.cpp +++ b/tests/std/tests/VSO_0000000_regex_use/test.cpp @@ -2223,6 +2223,15 @@ void test_gh_5790() { } } +void test_gh_5792() { + // GH-5792: : regex_match() throws regex_error(error_stack) + // when a repeated pattern contains a lookahead assertion + g_regexTester.should_match("", "(?:(?=ab))*"); + g_regexTester.should_match("", "(?:(?!ab))*"); + g_regexTester.should_not_match("bc", "(?:(?=ab))+bc"); + g_regexTester.should_match("bc", "(?:(?!ab))+bc"); +} + int main() { test_dev10_449367_case_insensitivity_should_work(); test_dev11_462743_regex_collate_should_not_disable_regex_icase(); @@ -2276,6 +2285,7 @@ int main() { test_gh_5672(); test_gh_5774(); test_gh_5790(); + test_gh_5792(); return g_regexTester.result(); }