<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Marshall Clow</b> <span dir="ltr"><<a href="mailto:mclow.lists@gmail.com">mclow.lists@gmail.com</a>></span><br>Date: Wed, Jul 22, 2015 at 8:27 PM<br>Subject: Re: [cfe-dev] [libc++] expected behavior for ECMAScript regex starting with '?'<br>To: Trevor Smigiel <<a href="mailto:tsmigiel@yahoo.com">tsmigiel@yahoo.com</a>><br><br><br><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Jul 21, 2015 at 9:54 PM, Trevor Smigiel <span dir="ltr"><<a href="mailto:tsmigiel@yahoo.com" target="_blank">tsmigiel@yahoo.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">Hi,<br>
<br>
When specifying an ECMAScript regex that starts with '?', like the test<br>
case below,  I was expecting it to throw an error.  If I use the<br>
resulting regex to match a string, it returns a match of length 0 at the<br>
first position.<br>
<br>
Looking at the regex grammar from the spec for ECMAScript, section<br>
15.10, it seems a '?' should not be allowed as the first character, but<br>
I did not read more than the grammar.<br>
</span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__wayback.archive.org_web_20111103184035_http-3A__www.ecma-2Dinternational.org_publications_files_ECMA-2DST_ECMA-2D262-2520edition-25205.1-2C-2520June-25202011.pdf&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=0Y3VqUnXeHWcqIqdVtR7VDFJQP8QmpfthR4lpR6IBFE&s=gcV2FpF3e9N6tYU4OEC_WMqPoZwFZfLAvHhwK0iALkE&e=" rel="noreferrer" target="_blank">http://wayback.archive.org/web/20111103184035/http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262%20edition%205.1,%20June%202011.pdf</a><span class=""><br>
<br>
What is the expected behavior?<br>
<br>
Thanks,<br>
Trevor<br>
<br>
// this test case is a modified version of the test from<br>
</span><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D16023&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=0Y3VqUnXeHWcqIqdVtR7VDFJQP8QmpfthR4lpR6IBFE&s=ojFnehssow4W0DcMOY_v5Mhb7NC9_BR2mwP0uIGmuJ8&e=" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=16023</a><span class=""><br>
#include <regex><br>
#include <cassert><br>
<br>
int main()<br>
    // Failure: No exception thrown for invalid escape char in this<br>
    case.<br>
    try {<br>
        std::regex escape("?a");<br>
        assert(false);<br>
    } catch (std::regex_error &ex) {<br>
        assert(ex.code() == std::regex_constants::error_escape);<br>
    }<br>
}<br><br></span></blockquote><div><br></div><div>Yes, looks like a bug.</div><div>Please file a bug at <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_bugs&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=0Y3VqUnXeHWcqIqdVtR7VDFJQP8QmpfthR4lpR6IBFE&s=U4t9rSzBrPYVBk36gLNh88Gw5vf4ss8-nVdb1QuwtNk&e=" target="_blank">llvm.org/bugs</a> ; assign it to the libc++ project, and to me.</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- Marshall</div></font></span><div> </div></div>P.S.  Both gcc and VS throw on that regex, but neither one throws "error_escape"</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>
</div><br></div>