[libc++] expected behavior for ECMAScript regex starting with '?'

Hi,

When specifying an ECMAScript regex that starts with '?', like the test
case below, I was expecting it to throw an error. If I use the
resulting regex to match a string, it returns a match of length 0 at the
first position.

Looking at the regex grammar from the spec for ECMAScript, section
15.10, it seems a '?' should not be allowed as the first character, but
I did not read more than the grammar.

What is the expected behavior?

Thanks,
Trevor

// this test case is a modified version of the test from
https://llvm.org/bugs/show_bug.cgi?id=16023
#include <regex>
#include <cassert>

int main()
    // Failure: No exception thrown for invalid escape char in this
    case.
    try {
        std::regex escape("?a");
        assert(false);
    } catch (std::regex_error &ex) {
        assert(ex.code() == std::regex_constants::error_escape);
    }
}

Hi,

When specifying an ECMAScript regex that starts with '?', like the test
case below, I was expecting it to throw an error. If I use the
resulting regex to match a string, it returns a match of length 0 at the
first position.

Looking at the regex grammar from the spec for ECMAScript, section
15.10, it seems a '?' should not be allowed as the first character, but
I did not read more than the grammar.

http://wayback.archive.org/web/20111103184035/http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262%20edition%205.1,%20June%202011.pdf

What is the expected behavior?

Thanks,
Trevor

// this test case is a modified version of the test from
https://llvm.org/bugs/show_bug.cgi?id=16023
#include <regex>
#include <cassert>

int main()
    // Failure: No exception thrown for invalid escape char in this
    case.
    try {
        std::regex escape("?a");
        assert(false);
    } catch (std::regex_error &ex) {
        assert(ex.code() == std::regex_constants::error_escape);
    }
}

Yes, looks like a bug.
Please file a bug at llvm.org/bugs ; assign it to the libc++ project, and
to me.

Thanks!

-- Marshall

P.S. Both gcc and VS throw on that regex, but neither one throws
"error_escape"