[Issue 10298] New: CTFE fails with array literal initialization

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 8 01:17:00 PDT 2013


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

           Summary: CTFE fails with array literal initialization
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at digitalmars.com


--- Comment #0 from Walter Bright <bugzilla at digitalmars.com> 2013-06-08 01:16:57 PDT ---
The following code works at runtime, but fails when initialized with a literal:

------------------
struct Bug7940 {
    int m;
}

struct App7940 {
   Bug7940[] x;
}

int bug7940() {
  Bug7940[2] y = [Bug7940(),Bug7940()]; // this line causes the failure
  //Bug7940[2] y;    // works
  App7940 app;
  app.x = y[0..1];
  app.x[0].m = 12;
  assert(y[0].m == 12);
  assert(app.x[0].m == 12);
  return 1;
}

static assert(bug7940());   // fails CTFE

void main()
{
    assert(bug7940());  //  works at runtime
}

-- 
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