digitalmars.D - struct default constructor, unions and bizaro behavior.
- deadalnix (14/14) Dec 10 2014 struct S {
- Walter Bright (2/16) Dec 10 2014 Please file a bug report.
- deadalnix (5/6) Dec 10 2014 I did, kenji told me that this is as per design and expected. I
- Steven Schveighoffer (6/20) Dec 11 2014 I'm not sure it's reasonable to expect this much out of the
- deadalnix (7/12) Dec 11 2014 I ran into this issue because of another bug that prevent the
- Steven Schveighoffer (4/9) Dec 12 2014 Which one then? :)
- deadalnix (3/6) Dec 12 2014 One, having an union type.
- Dicebot (2/16) Dec 11 2014 Isn't using named union instead an option?
struct S { union { T1 t1; T2 t2; } T3 t3; } T1 a1; T3 a3; S(a1, a3); This is erroring because t1 is set twice. It turns out that the second parameter of the struct map to t2 rather than t3. This behavior do not make any sense, ever. Why is that the default ?
Dec 10 2014
On 12/10/2014 1:57 PM, deadalnix wrote:struct S { union { T1 t1; T2 t2; } T3 t3; } T1 a1; T3 a3; S(a1, a3); This is erroring because t1 is set twice. It turns out that the second parameter of the struct map to t2 rather than t3. This behavior do not make any sense, ever. Why is that the default ?Please file a bug report.
Dec 10 2014
On Thursday, 11 December 2014 at 03:33:01 UTC, Walter Bright wrote:Please file a bug report.I did, kenji told me that this is as per design and expected. I don't think this design make any sense, so u bring the thing here :)
Dec 10 2014
On 12/10/14 4:57 PM, deadalnix wrote:struct S { union { T1 t1; T2 t2; } T3 t3; } T1 a1; T3 a3; S(a1, a3); This is erroring because t1 is set twice. It turns out that the second parameter of the struct map to t2 rather than t3. This behavior do not make any sense, ever. Why is that the default ?I'm not sure it's reasonable to expect this much out of the compiler-generated default ctor. It probably just does the equivalent of this.tupleof[0..args.length] = args; Can't you just add a constructor for it? -Steve
Dec 11 2014
On Thursday, 11 December 2014 at 16:20:33 UTC, Steven Schveighoffer wrote:I'm not sure it's reasonable to expect this much out of the compiler-generated default ctor. It probably just does the equivalent of this.tupleof[0..args.length] = args; Can't you just add a constructor for it? -SteveI ran into this issue because of another bug that prevent the default constructor to be found in some template mixin madness piece of code :) Anyway, I think this is reasonable to have one element for the union in the tupleof as well.
Dec 11 2014
On 12/11/14 6:15 PM, deadalnix wrote:I ran into this issue because of another bug that prevent the default constructor to be found in some template mixin madness piece of code :)Ah, template-mixin madness! Sounds contagious...Anyway, I think this is reasonable to have one element for the union in the tupleof as well.Which one then? :) -Steve
Dec 12 2014
On Friday, 12 December 2014 at 16:23:48 UTC, Steven Schveighoffer wrote:One, having an union type.Anyway, I think this is reasonable to have one element for the union in the tupleof as well.Which one then? :)
Dec 12 2014
On Wednesday, 10 December 2014 at 21:57:42 UTC, deadalnix wrote:struct S { union { T1 t1; T2 t2; } T3 t3; } T1 a1; T3 a3; S(a1, a3); This is erroring because t1 is set twice. It turns out that the second parameter of the struct map to t2 rather than t3. This behavior do not make any sense, ever. Why is that the default ?Isn't using named union instead an option?
Dec 11 2014