digitalmars.D.bugs - [Issue 9989] New: destructor triggers creation of opAssign for structs
- d-bugmail puremagic.com (33/33) Apr 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9989
- d-bugmail puremagic.com (10/10) Apr 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9989
- d-bugmail puremagic.com (17/17) Apr 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9989
- d-bugmail puremagic.com (10/17) Apr 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9989
http://d.puremagic.com/issues/show_bug.cgi?id=9989 Summary: destructor triggers creation of opAssign for structs Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: monarchdodra gmail.com As discussed here: https://github.com/D-Programming-Language/phobos/pull/1260 Declaring a destructor in a struct triggers the creation of an opAssign. It shouldn't. Note that it doesn't create a postblit (which is correct): //-------- struct S { ~this(){} } void main() { S s; s.opAssign(s); //OK, should fail. s.__postblit(); //Correctly fails. } //-------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9989 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull https://github.com/D-Programming-Language/dmd/pull/1935 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9989 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID 00:50:15 PDT --- The reason an opAssign is generated if a destructor is present is because assignment can no longer just copy over the data. The destructor must be run, and the generated opAssign ensures that. The generated opAssign looks like: S tmp = this; // bit copy this = s; // bit copy tmp.dtor(); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9989The reason an opAssign is generated if a destructor is present is because assignment can no longer just copy over the data. The destructor must be run, and the generated opAssign ensures that. The generated opAssign looks like: S tmp = this; // bit copy this = s; // bit copy tmp.dtor();OK. it is sane behavior, and my fix was not correct. But, if so, current dmd generates wrong code for struct S. I filed new issue for the problem. Issue 9994 - Built-in generated opAssign should call dtor on assignment -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2013