Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Maxim Fomin
On Saturday, 29 September 2012 at 23:02:08 UTC, Timon Gehr wrote: On 09/30/2012 12:51 AM, Ali Çehreli wrote: Disclaimer: I assume that D's rules are the same as C and C++ here. C and C++ do not have struct literals and if I am not mistaken, constructor invocation is a sequence point. S(4,

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Ali Çehreli
On 09/29/2012 08:13 PM, ixid wrote: > On Sunday, 30 September 2012 at 00:24:34 UTC, Ali Çehreli wrote: >> On 09/29/2012 04:02 PM, Timon Gehr wrote: >> > On 09/30/2012 12:51 AM, Ali Çehreli wrote: >> >> On 09/29/2012 11:16 AM, Timon Gehr wrote: >> >> > On 09/29/2012 06:26 PM, Maxim Fomin wrote: >>

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread ixid
On Sunday, 30 September 2012 at 00:24:34 UTC, Ali Çehreli wrote: On 09/29/2012 04:02 PM, Timon Gehr wrote: > On 09/30/2012 12:51 AM, Ali Çehreli wrote: >> On 09/29/2012 11:16 AM, Timon Gehr wrote: >> > On 09/29/2012 06:26 PM, Maxim Fomin wrote: >> >> >>> S s = S(1,2,3); >> >>> s = S(4, s.a, 6); >

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Ali Çehreli
On 09/29/2012 04:02 PM, Timon Gehr wrote: > On 09/30/2012 12:51 AM, Ali Çehreli wrote: >> On 09/29/2012 11:16 AM, Timon Gehr wrote: >> > On 09/29/2012 06:26 PM, Maxim Fomin wrote: >> >> >>> S s = S(1,2,3); >> >>> s = S(4, s.a, 6); >> >>> >> >>> assert(a == [4,1,6]); >> >>> assert(s == S(4,4,6)); >

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Timon Gehr
On 09/30/2012 12:51 AM, Ali Çehreli wrote: On 09/29/2012 11:16 AM, Timon Gehr wrote: > On 09/29/2012 06:26 PM, Maxim Fomin wrote: >>> 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 evaluat

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Ali Çehreli
On 09/29/2012 11:16 AM, Timon Gehr wrote: > On 09/29/2012 06:26 PM, Maxim Fomin wrote: >>> 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 ass

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Tommi
On Saturday, 29 September 2012 at 18:16:24 UTC, Timon Gehr wrote: This seems to be a DMD bug. And a pretty serious looking one at that. That bug could make nukes fly to wrong coordinates, and that just ruins everybody's day.

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Timon Gehr
On 09/29/2012 06:26 PM, Maxim Fomin wrote: On Saturday, 29 September 2012 at 16:05:03 UTC, ixid wrote: 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,

Re: Struct assignment, possible DMD bug?

2012-09-29 Thread Maxim Fomin
On Saturday, 29 September 2012 at 16:05:03 UTC, ixid wrote: 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);

Struct assignment, possible DMD bug?

2012-09-29 Thread ixid
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)); } Set