Thread overview |
---|
August 22, 2010 [Issue 4712] New: Issue of destructor for temporary instance of structs | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4712 Summary: Issue of destructor for temporary instance of structs Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: zan77137@nifty.com --- Comment #0 from SHOO <zan77137@nifty.com> 2010-08-22 06:29:06 PDT --- This code doesn't work! import std.stdio; auto func(int A = int.init)() { struct XXX { int a; ~this(){ writeln("dtor"); } } return XXX(); } void main() { writeln("start"); { auto x = func!(); } writeln("end"); } result: start dtor end object.Error: Access Violation If I remove the destructor, it runs correctly. Or I set -O switch to compiler, it runs correctly, too. Workaround for this bug is making dummy constructor: import std.stdio; auto func(int A = int.init)() { struct XXX { int a; this(int aa){ a = aa; writeln("ctor"); } ~this(){ writeln("dtor"); } } return XXX(A); } void main() { writeln("start"); { auto x = func!(); } writeln("end"); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 22, 2010 [Issue 4712] Issue of destructor for temporary instance of structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to SHOO | http://d.puremagic.com/issues/show_bug.cgi?id=4712 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-08-22 12:43:53 PDT --- Is this the same as bug 3516? The fact that turning on the optimiser is not mentioned there, and may indicate it's a different bug. But they seem to be closely related. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 20, 2010 [Issue 4712] Issue of destructor for temporary instance of structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to SHOO | http://d.puremagic.com/issues/show_bug.cgi?id=4712 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Severity|normal |critical -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 14, 2010 [Issue 4712] Issue of destructor for temporary instance of structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to SHOO | http://d.puremagic.com/issues/show_bug.cgi?id=4712 SHOO <zan77137@nifty.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #2 from SHOO <zan77137@nifty.com> 2010-11-14 09:59:35 PST --- This issue is already fixed. (Because it was fixed before I knew it, I don't know revision clearly.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation