Summary: Destructor not called
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD

import std.stdio;

struct S {
    this(int x) {
        writefln("this(%s)", x);
        this.x = x;
    this(this) {
        writefln("this(this) with %s", x);
    ~this() {
        writefln("Going away S(%s)", x);
    int x;

S fun1() {
    auto s = S(1);
    return s;

S fun2() {
    return S(2);

void main() {
    //auto s1 = fun1;
    auto s2 = fun2;

This example creates two objects but only destroys one. fun1 illustrates the
correct behavior.


Reply via email to