Open
Description
Bugzilla Link | 51686 |
Version | 12.0 |
OS | All |
CC | @mclow,@utsumi-fj,@wkensuke |
Extended Description
#include <regex>
#include <cassert>
#include <cstdio>
static bool error_range_thrown(const char *pat)
{
bool result = false;
try {
std::regex re(pat);
} catch (const std::regex_error &ex) {
puts("regex_error");
fflush(stdout);
result = (ex.code() == std::regex_constants::error_range);
}
return result;
}
int main(int, char**) {
assert(error_range_thrown("([b-a])"));
}
This program is created using the regular expression sample described in the C++ language standard, but it did not throw an exception (as expected).
(e.g., Table 132 in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4713.pdf)
I've confirmed that this problem can be reproduced using clang 13.0.0 "[C++] clang HEAD 13.0.0 (https://github.com/llvm/llvm-project.git c4ed142)" on Wandbox (https://wandbox.org/).
This code throws the exception on gcc-10.1.0 (or other gcc version).