[Issue 6499] [GSoC] Destructor not called on object returned by	method.
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Aug 16 06:18:16 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6499
Cristi Cobzarenco <cristi.cobzarenco at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
--- Comment #3 from Cristi Cobzarenco <cristi.cobzarenco at gmail.com> 2011-08-16 06:18:13 PDT ---
Thanks for the fix Kenji. However, this still doesn't work if bar() is a
template function, i.e:
struct Bar {
    string m = "<not set>";
    this( string s ) { writeln( "Constructor - ", m = s ); }
    this( this )     { writeln( "Postblit    - ", m ); }
    ~this()          { writeln( "Destructor  - ", m ); }
    // NOTE: bar is a template, otherwise it works
    Bar bar()()      { return Bar( "bar" ); }
}
Bar foo() { return Bar( "foo" ); }    
void main() {
    foo().bar();
}
Outputs:
Constructor - foo
Constructor - bar
Destructor  - bar
Interestingly, this time it's the one returned by foo() that doesn't get
destroyed, rather than the one returned by bar().
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list