Re: Valid to assign to field of struct in union?

2016-09-07 Thread Timon Gehr via Digitalmars-d
On 06.09.2016 22:44, Johan Engelen wrote: On Tuesday, 6 September 2016 at 17:58:44 UTC, Timon Gehr wrote: I don't think so (although your case could be made to work easily enough). This seems to be accepts-invalid. What do you think of the original example [1] in the bug report that uses `mix

Re: Valid to assign to field of struct in union?

2016-09-06 Thread Johan Engelen via Digitalmars-d
On Tuesday, 6 September 2016 at 17:58:44 UTC, Timon Gehr wrote: I don't think so (although your case could be made to work easily enough). This seems to be accepts-invalid. What do you think of the original example [1] in the bug report that uses `mixin Proxy!i;` ? [1] https://issues.dlang

Re: Valid to assign to field of struct in union?

2016-09-06 Thread Timon Gehr via Digitalmars-d
On 06.09.2016 14:56, Johan Engelen wrote: Hi all, I have a question about the validity of this code: ``` void main() { struct A { int i; } struct S { union U { A first; A second; } U u; this(A val)

Re: Valid to assign to field of struct in union?

2016-09-06 Thread Johan Engelen via Digitalmars-d
On Tuesday, 6 September 2016 at 12:56:24 UTC, Johan Engelen wrote: The compiler allows it, but it leads to a bug with CTFE of this code: the assert fails. Before someone smart tries it, yes the code works with LDC, but wait... swap the order of `first` and `second` in the union, and BOOM! I

Valid to assign to field of struct in union?

2016-09-06 Thread Johan Engelen via Digitalmars-d
Hi all, I have a question about the validity of this code: ``` void main() { struct A { int i; } struct S { union U { A first; A second; } U u; this(A val) { u.second = val; a