Struct assignment, possible DMD bug?

ixid nuaccount at gmail.com
Sat Sep 29 09:05:31 PDT 2012


This behaviour seems inconsistent and unintuitive:

void main() {
	int[3] a = [1,2,3];
	a = [4, a[0], 6];

	struct S {
		int a, b, c;
	}

	S s = S(1,2,3);
	s = S(4, s.a, 6);

	assert(a == [4,1,6]);
	assert(s == S(4,4,6));
}

Setting the struct writes s.a before evaluating it while the 
reverse is true of the array assignment. Using DMD 2.0.60. GDC 
does what I'd expect and gives both as 4,1,6.


More information about the Digitalmars-d-learn mailing list