Re: Casting random type to random struct - is this a bug?

2015-07-16 Thread rumbu via Digitalmars-d-learn
On Wednesday, 15 July 2015 at 15:58:17 UTC, Daniel Kozák wrote: On Wed, 15 Jul 2015 15:45:43 + rumbu ru...@rumbu.ro wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the

Casting random type to random struct - is this a bug?

2015-07-15 Thread rumbu via Digitalmars-d-learn
struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the first position. Is this normal behaviour?

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 11:57:01 -0400 Steven Schveighoffer schvei...@yahoo.com wrote: On 7/15/15 11:45 AM, rumbu wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/15/15 11:45 AM, rumbu wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the first position. Is this normal behaviour? I would say this is a bug. As far as I know, it's not

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 15:45:43 + rumbu ru...@rumbu.ro wrote: struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the first position. Is this normal behaviour? Yes, this is OK