diff --git a/stl/inc/regex b/stl/inc/regex index 8324e64f25a..cee712db569 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -3521,7 +3521,7 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Is_wbound() const { } } else { // --_Cur is not valid if (_Tgt_state._Cur == _End) { - return (_Mflags & (regex_constants::match_not_bow | regex_constants::match_not_eow)) == 0; + return false; } else { return (_Mflags & regex_constants::match_not_bow) == 0 && _Is_word(*_Tgt_state._Cur); } diff --git a/tests/std/tests/VSO_0000000_regex_use/test.cpp b/tests/std/tests/VSO_0000000_regex_use/test.cpp index 6f3a5bb1270..78c47380598 100644 --- a/tests/std/tests/VSO_0000000_regex_use/test.cpp +++ b/tests/std/tests/VSO_0000000_regex_use/test.cpp @@ -499,7 +499,7 @@ void test_VSO_225160_match_eol_flag() { void test_VSO_226914_word_boundaries() { const test_regex emptyAnchor(&g_regexTester, R"(\b)"); - emptyAnchor.should_search_match("", ""); + emptyAnchor.should_search_fail(""); emptyAnchor.should_search_fail("", match_not_bow); emptyAnchor.should_search_fail("", match_not_eow); emptyAnchor.should_search_fail("", match_not_bow | match_not_eow); @@ -1434,6 +1434,12 @@ void test_gh_5364() { g_regexTester.should_match("c", "[^]", ECMAScript); } +void test_gh_5371() { + // GH-5371 : \b and \B are backwards on empty strings + g_regexTester.should_not_match("", R"(\b)"); + g_regexTester.should_match("", R"(\B)"); +} + int main() { test_dev10_449367_case_insensitivity_should_work(); test_dev11_462743_regex_collate_should_not_disable_regex_icase(); @@ -1474,6 +1480,7 @@ int main() { test_gh_5253(); test_gh_5362(); test_gh_5364(); + test_gh_5371(); return g_regexTester.result(); }