www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12640] New: nogc introduces a spurious switch case

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

          Issue ID: 12640
           Summary:  nogc introduces a spurious switch case fallthrough
                    warning
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

void main()  nogc {
    int[1] bar;
    int x;
    switch (x) {
        case 0:
            bar = [x];
            break;
        default:
    }
}



DMD 2.066alpha gives this, the warning is false (a rejects-valid, you can see
it removing the  nogc annotation):

test.d(6,19): Error: array literals in  nogc function main may cause GC
allocation
test.d(8,9): Warning: switch case fallthrough - use 'goto default;' if intended

--
Apr 24 2014