[Issue 1948] New: CTFE fails when mutating a struct in an array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 26 10:47:46 PDT 2008


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

           Summary: CTFE fails when mutating a struct in an array
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: samukha at voliacable.com


Error: cannot evaluate foo() at compile time

struct S
{
    int x;
}

int foo()
{
    S[] a = [];
    a ~= S();

    a[0].x = 1; // Fails 

    return 0;
}

enum x = foo();

Btw, CTFE is relatively difficult to debug. More informative messages than
"cannot evaluate ... at compile time" would be appreciated.


-- 



More information about the Digitalmars-d-bugs mailing list