Is this a bug in dmd 2.067 for struct initializers?

stewarth via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 18 22:39:17 PST 2015


Hi All,

This works under dmd 2066.1 but fails under dmd 2.067-b2.

---
struct A {
     int val;
}

static immutable A[] someA = [{val:1}, {val:2}];

struct B {
     A* a;
}

static immutable B[] someB = [{a:&someA[0]}, {a:&someA[1]}];

void main()
{

     writefln("a:%s", someA);
     writefln("b:%s", someB);
}
---
Error under DMD 2.067-b2:

hack.d(27): Error: cannot use non-constant CTFE pointer in an 
initializer '&[A(1), A(2)][0]'
hack.d(27): Error: cannot use non-constant CTFE pointer in an 
initializer '&[A(1), A(2)][1]'


Is this a bug, or a deliberate change?

I'm thinking a bug because I want it to initialize at runtime 
before main(). I don't actually want any CTFE stuff here.

Thanks,
stew


More information about the Digitalmars-d-learn mailing list