digitalmars.D.bugs - [Issue 6080] New: Statically constructed Structs - Constructor/Initialization ambiguity
- d-bugmail puremagic.com (27/27) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6080
- d-bugmail puremagic.com (7/7) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6080
- d-bugmail puremagic.com (10/10) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6080
- d-bugmail puremagic.com (32/32) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6080
- d-bugmail puremagic.com (6/6) May 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6080
http://d.puremagic.com/issues/show_bug.cgi?id=6080 Summary: Statically constructed Structs - Constructor/Initialization ambiguity Product: D Version: unspecified Platform: x86_64 OS/Version: Linux Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: daniel350 bigpond.com --- Comment #0 from Daniel <daniel350 bigpond.com> 2011-05-31 02:24:08 PDT --- SO Question: http://stackoverflow.com/questions/6184422/ambiguous-struct-constructors-in-d Source example: http://www.pastie.org/1997238 Actual Output: 5,3 2,8 2,10 Expected Output: 2,10 2,8 2,10 If the above doesn't provide all the information, then I'll summarize: Statically constructed structs are defaulting to the parameter list initialization instead of using a constructor. I'm to assume this is a bug, and possibly a flaw in ambiguity, at least a warning should be displayed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6080 --- Comment #1 from Daniel <daniel350 bigpond.com> 2011-05-31 02:24:56 PDT --- And, it should be consistent between statically defined and locally defined structs? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6080 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-05-31 03:07:51 PDT --- A similar bug, but for enums, is reported in issue 5460. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6080 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #3 from bearophile_hugs eml.cc 2011-05-31 04:13:00 PDT --- Please, don't link code that's in external paste sites, because their pages are often ephemeral. The code, with small changes: import core.stdc.stdio: printf; struct Foo { int a = 2; int b = 3; this(int c) { a = c / 2; b = c * 2; } this(float c) { a = cast(int) c / 2; b = cast(int) c * 2; } static Foo F1 = Foo(4.3); static Foo F2 = Foo(5); } void main() { printf("%d %d\n", Foo.F1.a, Foo.F1.b); // 2 8 printf("%d %d\n", Foo.F2.a, Foo.F2.b); // 5 3 Foo F3 = Foo(5); printf("%d %d\n", F3.a, F3.b); // 2 10 } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6080 --- Comment #4 from Daniel <daniel350 bigpond.com> 2011-05-31 16:32:01 PDT --- Thanks for simplifying it mate. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 31 2011