[Issue 17111] New: DMD accepts switch statement with non-const case variables

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jan 20 12:29:29 PST 2017


https://issues.dlang.org/show_bug.cgi?id=17111

          Issue ID: 17111
           Summary: DMD accepts switch statement with non-const case
                    variables
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: yshuiv7 at gmail.com

Example:

void main() {
    alias TestType = ulong; // won't compile if = ubyte
    import std.stdio;
    TestType a,b,c;
    readf("%s %s %s ", &a, &b, &c);
    switch(c){
        case a: writeln("a");break;
        case b: writeln("b");break;
        default: assert(false);
    }
}

Forum thread:

https://forum.dlang.org/post/djfkbbtuckczxmeunmgt@forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list