Is this a bug?

Jerry jlquinn at optonline.net
Tue Nov 26 15:33:28 PST 2013


If I read correctly, the following is legal code.  If you comment out
one of the case statements, it does the expected thing.  With 4 or more,
it crashes.  This is with dmd 2.064.2 on Debian.

If it's a bug, I'll file a report.  Thanks!

class BB {}
class DD : CC {}
class CC : BB {
  static CC create(string s) {
    // Succeeds with 3 cases, fails with 4
    switch (s) {
    case "en":
    case "it":
    case "ru":
    case "ko": return new DD;
    default: throw new Exception("blech");
    }
  }
}

void main() {
    CC.create("en");
}

jlquinn at wyvern:~/d$ ~/dmd2/linux/bin64/dmd switchbug.d -g
jlquinn at wyvern:~/d$ ./switchbug 
Segmentation fault (core dumped)





More information about the Digitalmars-d mailing list