[Issue 5826] New: Error: Statement SwitchErrorStatement::toCBuffer() cannot be interpreted at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 9 12:23:49 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5826

           Summary: Error: Statement SwitchErrorStatement::toCBuffer()
                    cannot be interpreted at compile time
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ibuclaw at ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2011-04-09 12:20:08 PDT ---
>From fail_compilation/fail146.d:

int bar(int i)
{
    switch (i)
    {
        case 1:
            i = 4;
            break;
        case 8:
            i = 3;
            break;
    }
    return i;
}

void main()
{
    static b = bar(7);
    printf("b = %d, %d\n", b, bar(7));
    assert(b == 3);
}



Error message:
fail_compilation/fail146.d(4): Error: no default or case for 7 in switch
statement
fail_compilation/fail146.d(4): Error: Statement
SwitchErrorStatement::toCBuffer()
 cannot be interpreted at compile time
fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
fail_compilation/fail146.d(19): Error: 'printf' is not defined, perhaps you
need to import core.stdc.stdio; ?


For all intent and purposes, this line:

fail_compilation/fail146.d(4): Error: Statement
SwitchErrorStatement::toCBuffer() cannot be interpreted at compile time

Should ideally not be emitted as an error.

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list