digitalmars.D.bugs - [Issue 6768] New: Problem with init of struct members in presence of templated opAssign
- d-bugmail puremagic.com (52/52) Oct 04 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6768
- d-bugmail puremagic.com (10/10) Jan 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6768
- d-bugmail puremagic.com (23/25) Feb 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6768
- d-bugmail puremagic.com (56/56) Nov 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6768
http://d.puremagic.com/issues/show_bug.cgi?id=6768 Summary: Problem with init of struct members in presence of templated opAssign Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-10-04 19:14:34 PDT --- module test; import std.traits; import std.stdio; struct Point { int x, y; void delegate() dg; // void opAssign(void delegate() rhs) // ok, x and y initialized // { // dg = rhs; // } void opAssign(T)(T rhs) if (isDelegate!T) // x and y left uninitialized { dg = rhs; } void test() { dg(); } } class Foo { this() { point = { writefln("Point: %s", point); }; // assign delegate } Point point; } void main() { auto foo = new Foo; foo.point.dg(); // x and y are initialized foo.point.test(); // but here x and y are not initialized (??) foo.point.dg(); // again, not initialized (??) } I don't understand how calling dg() directly or indirectly via test() prints different results for x and y. If I use the non-templated version of opAssign then both calls are fine, with x and y being zero-inited. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6768 --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-01-04 06:49:54 PST --- In 2.057 all calls to the `dg` delegate print garbage values if the templated opAssign was used: Point: Point(4202703, 4931824, void delegate()) Point: Point(1244728, 4202612, void delegate()) Point: Point(4202726, 4931824, void delegate()) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 04 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6768 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |smjg iname.com Platform|Other |All Blocks| |2573 --- Comment #2 from Stewart Gordon <smjg iname.com> 2012-02-12 13:05:02 PST --- (In reply to comment #1)In 2.057 all calls to the `dg` delegate print garbage values if the templated opAssign was used:Not for me (2.057 Win32): ----- C:\Users\Stewart\Documents\Programming\D\Tests\bugs>bz6768 Point: Point(0, 0, void delegate()) Point: Point(1244752, 4202612, void delegate()) Point: Point(1244752, 4202612, void delegate()) ----- It's especially puzzling because after construction of foo, our code hasn't changed either foo or foo.point, but something behind the scenes has caused it to change. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6768 Denis Shelomovskij <verylonglogin.reg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |verylonglogin.reg gmail.com Resolution| |DUPLICATE --- Comment #3 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2012-11-12 12:25:48 MSK --- The issue isn't with `opAssign`. It is because closure isn't detected: --- import std.stdio; void setDel()(Foo foo, void delegate() del) { foo.del = del; } class Foo { void delegate() del; void f() { writefln("%X, %X (instance and ref addresses)", cast(void*) this, &this); void g() { writefln("%X, %X (instance and ref addresses from g)", cast(void*) this, &this); } setDel(this, &g); writefln("%X (del.ptr)", del.ptr); } void callDel() { writefln("+callDel"); del(); writefln("-callDel"); } } void main() { auto foo = new Foo(); foo.f(); foo.del(); foo.callDel(); foo.del(); } --- Output: --- A01E70, 12FE58 (instance and ref addresses) 12FE58 (del.ptr) 12FE58, 12FE58 (instance and ref addresses from g) +callDel A01E70, 12FE58 (instance and ref addresses from g) -callDel 12FE58, 12FE58 (instance and ref addresses from g) --- Created a new issue with corrected title and description. *** This issue has been marked as a duplicate of issue 8999 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 12 2012