Skip to content

Commit 70ff63d

Browse files
author
alexey.lazarev
committed
[libc++][regex] Fix #51028 throw exception in the case of wrong range
1 parent abb8784 commit 70ff63d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

libcxx/include/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ public:
21202120
__ranges_.push_back(
21212121
std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end())));
21222122
} else {
2123-
if (__b.size() != 1 || __e.size() != 1)
2123+
if (__b.size() != 1 || __e.size() != 1 || __b[0] > __e[0])
21242124
std::__throw_regex_error<regex_constants::error_range>();
21252125
if (__icase_) {
21262126
__b[0] = __traits_.translate_nocase(__b[0]);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// template <class ST, class SA>
1515
// basic_regex(const basic_string<charT, ST, SA>& s);
1616

17+
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
18+
1719
#include <regex>
1820
#include <cassert>
1921
#include "test_macros.h"
@@ -33,6 +35,7 @@ int main(int, char**)
3335
{
3436
assert(error_range_thrown("([\\w-a])"));
3537
assert(error_range_thrown("([a-\\w])"));
38+
assert(error_range_thrown("([w-a])"));
3639

37-
return 0;
40+
return 0;
3841
}

0 commit comments

Comments
 (0)