On 17.08.2011 3:47, bearophile wrote:
Dmitry Olshansky:

To get a small no-crap-included beta package see download section of
https://github.com/blackwhale/FReD for .7zs.
I have not patched DMD, but it gives me some problem here:

void parseFlags(S)(S flags)
{
     foreach(ch; flags)//flags are ASCII anyway
     {
         switch(ch)
         {

             foreach(i, op; __traits(allMembers, RegexOption))
             {
                 case RegexOptionNames[i]:
                         if(re_flags&  mixin("RegexOption."~op))
                             throw new RegexException(text("redundant flag 
specified: ",ch));
                         re_flags |= mixin("RegexOption."~op);
                         break;
             }
             default:
                 if(__ctfe)
                    assert(text("unknown regex flag '",ch,"'"));
                 else
                     new RegexException(text("unknown regex flag '",ch,"'"));
         }


To better see the situation I have written a small test case:

import std.typetuple: TypeTuple;

enum RegexOption : uint { A, B, C } // no need to put a semicolon here

alias TypeTuple!(RegexOption.A, RegexOption.B, RegexOption.C) RegexOptionNames;

void main() {
     RegexOption ch;

     switch (ch) {
         foreach (i, op; __traits(allMembers, RegexOption))
             case RegexOptionNames[i]: break;

         default: assert(0);
     }
}


test.d(12): Error: switch case fallthrough - use 'goto case;' if intended
test.d(12): Error: switch case fallthrough - use 'goto case;' if intended
test.d(12): Error: switch case fallthrough - use 'goto case;' if intended
test.d(14): Error: switch case fallthrough - use 'goto default;' if intended

This used to work, I think. The new DMD switch analysis seems to have a bug.

-------------
Yes, that's a bug. But it's not a regression, I assume you started to compile with -w, that's when it happens IIRC. I almost forgot about it, thanks for uncovering it again, you may as well file it.


If you want a benchmark, to compare it with other implementations, there is 
this one:
http://shootout.alioth.debian.org/debian/program.php?test=regexdna&lang=gdc&id=4


All in due time, though this one involves semi-fixed patterns, hm ... very promising.

--
Dmitry Olshansky

Reply via email to