digitalmars.D.bugs - [Issue 4356] New: Copy constructor not called under extremely mysterious circumstances
- d-bugmail puremagic.com (51/51) Jun 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4356
- d-bugmail puremagic.com (34/34) Jun 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4356
- d-bugmail puremagic.com (11/11) Jun 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4356
- d-bugmail puremagic.com (8/8) May 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4356
http://d.puremagic.com/issues/show_bug.cgi?id=4356 Summary: Copy constructor not called under extremely mysterious circumstances Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrei metalanguage.com 20:40:18 PDT --- I spent the better part of today trying to escape this elusive bug. It's extremely subtle because it depends on some unrelated code existing or not. Here it is: import std.stdio; struct X(T) { this(this) { writeln("I was copied"); } } void main() { struct A { X!int x; this(int y) { } A copy() { auto another = this; return another; } } auto a = A(4); auto b = a.copy(); writefln("a: %p, b: %p\n", &a, &b); } At the end of this program the writefln witnesses that we have two objects, but the stdout is mute so the subobject was not copied. Changing some code in the example above makes the example work. For example, replacing A(4) with A() produces a correct program. Please give this priority (as all ctor/dtor bugs should have). Thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 20 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4356 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com 02:13:46 PDT --- Simpler test case: import std.c.stdio; struct A { int m; this(this) { printf("this(this) %p\n", &this); } ~this() { printf("~this() %p\n", &this); } A copy() { A another = this; return another; } } void main() { A a; A b = a.copy(); printf("a: %p, b: %p\n", &a, &b); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4356 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED 22:15:06 PDT --- http://www.dsource.org/projects/dmd/changeset/555 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4356 Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/ca86dad193372aee89de3712dfab0589502f3564 Bug 4356 is fixed, use ordinary assertion. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012