Issue 110339
Summary Is the regex [b-a] legal?
Labels new issue
Assignees
Reporter Alcaro
    ```c++
#include <regex>

int main()
{
    try {
        std::regex r("[\\d-e]");
 puts("it's legal");
    } catch (std::exception& e) {
 puts(e.what());
    }
    try {
        std::regex r("[b-a]");
 puts("it's legal");
    } catch (std::exception& e) {
 puts(e.what());
 }
}
```

https://godbolt.org/z/oMvEr5YTs

Output: `The _expression_ contained an invalid character range, such as [b-a] in most encodings.` and `it's legal`

Expected behavior: I'd expect that if I can produce an error saying that [b-a] is invalid, then an input of [b-a] returns that same error.

(Also, if you change it to `[1-0]`, it's illegal in all encodings. The C and C++ specs demand that the 0-9 are ascending and consecutive.)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to