http://d.puremagic.com/issues/show_bug.cgi?id=6199
Summary: [GSoC] Postblit not called when returning a reference to a by-value function. Product: D Version: D2 Platform: All OS/Version: Windows Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: cristi.cobzare...@gmail.com --- Comment #0 from Cristi Cobzarenco <cristi.cobzare...@gmail.com> 2011-06-23 11:14:10 PDT --- Code: import std.stdio; struct Test { this( this ) { writeln( "postblit" ); } ~this() { writeln( "destroyed" ); } } void takesVal( Test x ) {} ref Test returnsRef( ref Test x ) { return x; } int main() { Test x; takesVal( returnsRef( x ) ); return 0; } -------------- Output: destroyed destroyed So while there is copy getting destroyed, the postblit doesn't get called. The code works fine when passing a ref argument: Code: [...] void f( ref Test x ) { takesVal( x ); } int main() { Test x; f( x ); } -------------- Output: postblit destroyed destroyed This bug is probably related to http://d.puremagic.com/issues/show_bug.cgi?id=5737 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------