digitalmars.D.bugs - [Issue 7058] New: static initializer for structs doesn't respect init values of members
- d-bugmail puremagic.com (39/39) Dec 02 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7058
- d-bugmail puremagic.com (40/40) Dec 02 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7058
- d-bugmail puremagic.com (12/12) May 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7058
http://d.puremagic.com/issues/show_bug.cgi?id=7058 Summary: static initializer for structs doesn't respect init values of members Product: D Version: D1 & D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: mrmocool gmx.de --- Comment #0 from Trass3r <mrmocool gmx.de> 2011-12-02 18:50:33 PST --- void main() { import std.stdio; vec3 v = {1.5f, 2}; // with vec3(1.5f, 2) z becomes 0 writeln(v); } struct vec3 { // union // { // struct // { float x = 0; float y = 0; float z = 0; // } // float[3] cell; // } } $ dmd -run vector.d vec3(1.5, 2, nan) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 02 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7058 --- Comment #1 from Trass3r <mrmocool gmx.de> 2011-12-02 19:04:09 PST --- Interestingly enough, if you add a tuple it only respects the first value at all: void main() { import std.stdio; vec3 v = {1.5f, 1.f, 0.5f}; writeln(v); } template Tuple(T...) { alias T Tuple; } template Repeat(T, int count) { static if (!count) alias Tuple!() Repeat; else alias Tuple!(T, Repeat!(T, count-1)) Repeat; } struct vec3 { union { struct { float x = 0; float y = 0; float z = 0; } // float[3] cell; Repeat!(float, 3) tuple; } } $ dmd -run vector.d vec3(1.5, nan, nan, 1.5, nan, nan) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 02 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7058 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |DUPLICATE --- Comment #2 from Don <clugdbug yahoo.com.au> 2012-05-29 01:02:58 PDT --- *** This issue has been marked as a duplicate of issue 4967 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 29 2012