https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119708
Bug ID: 119708
Summary: <regex>: \00 should be rejected
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
#include <regex>
#include <stdio.h>
int main() {
try {
std::regex r{"\\00"};
puts("valid");
} catch (const std::exception& e) {
printf("not valid: %s\n", e.what());
}
try {
std::regex r{"\\01"};
puts("valid");
} catch (const std::exception& e) {
printf("not valid: %s\n", e.what());
}
}
Expected: Reject them. 00 and 01 do not match DecimalIntegerLiteral in the JS
spec, and lookahead can't be a digit either.
Actual: Both are valid. (Can't find what they're actually parsed as, though.)
https://godbolt.org/z/heM1o1aGe
libc++ has the same bug. https://github.com/llvm/llvm-project/issues/135048