[cfe-dev] Fwd: [libc++] expected behavior for ECMAScript regex starting with '?'
Marshall Clow
mclow.lists at gmail.com
Wed Jul 22 20:28:14 PDT 2015
---------- Forwarded message ----------
From: Marshall Clow <mclow.lists at gmail.com>
Date: Wed, Jul 22, 2015 at 8:27 PM
Subject: Re: [cfe-dev] [libc++] expected behavior for ECMAScript regex
starting with '?'
To: Trevor Smigiel <tsmigiel at yahoo.com>
On Tue, Jul 21, 2015 at 9:54 PM, Trevor Smigiel <tsmigiel at yahoo.com> wrote:
> 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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150722/7a56c25d/attachment.html>
More information about the cfe-dev
mailing list