<div dir="ltr">When I was browsing regex header from libcxx, I found the following code:<div>
<p class="gmail-p1"><span class="gmail-s1">enum </span><span class="gmail-s2">syntax_option_type</span></p>
<p class="gmail-p2"><span class="gmail-s2">{</span></p>
<p class="gmail-p2"><span class="gmail-s2"> icase = 1 << 0,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> nosubs = 1 << 1,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> optimize = 1 << 2,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> collate = 1 << 3,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> ECMAScript = 0,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> basic = 1 << 4,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> extended = 1 << 5,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> awk = 1 << 6,</span></p>
<p class="gmail-p2"><span class="gmail-s2"> grep = 1 << 7,</span></p><p class="gmail-p2"> egrep = 1 << 8</p>
<p class="gmail-p2"><span class="gmail-s2">};</span></p><p class="gmail-p2"><span class="gmail-s2"><br></span></p><p class="gmail-p2"><span class="gmail-s2">syntax_option_type is an implementation-defined bitmask type. According to standard, bitmask elements have distinct, nonzero values. And the value 0 is used to represent an empty bitmask, in which no bitmask elements are set. </span></p><p class="gmail-p2"><span class="gmail-s2">Standard does mention that if no grammar element is set, the default grammar is ECMAScript. But ECMAScript still looks like a bitmask element inside of bitmask type syntax_option_type to me, which means it should be non-zero. </span></p><p class="gmail-p2">Interestingly, when I look at the history of regex header, ECMAScript was a non-zero value at some point, but got changed to 0 in a later commit. </p><p class="gmail-p2">So my questions are... Any reasons why we changed it to 0? (Maybe for cleaner implementation?) Is this still standard compliant? If not, should we modify it to be more standard compliant?</p><p class="gmail-p2">Thanks in advance!</p><p class="gmail-p2"><br></p><p class="gmail-p2">Regards,</p><p class="gmail-p2"><br></p><p class="gmail-p2">Jason Liu</p></div></div>