Skip to content

<regex>: R"([\d-e])" should be rejected #4995

Description

@Sir-Walrus

Describe the bug

The regex [\d-e] (character class containing the range \d to e) is accepted (treated as \d, and the literal characters - and e), contrary to the ECMA-262 spec (\d isn't a single character, so it can't be used like that)

Command-line test case

#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

Expected behavior

Both should be illegal (currently, only the latter is rejected)

STL version

Ask Godbolt

Additional context

Feel free to close this one as wontfix, if you feel it's ossified into a vendor extension. As long as it's a conscious choice, I'm fine with whichever outcome.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions