https://issues.dlang.org/show_bug.cgi?id=23561

Vital <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                 OS|Linux                       |Windows

--- Comment #1 from Vital <[email protected]> ---
import std.stdio;

static int i;

struct S
{
    ~this() { 
        i++; 
        writeln("DTOR: i == ", i ); 
    }
}


void main()
{
    {
        auto u = new S;
        u.destroy();
        // (*u).destroy(); // works fine!
    }

    import core.memory;
    GC.collect();

    writeln("EXIT: i == ", i ); // 0, but except 1

    assert(i == 1); // fails
}

// Output:
//   EXIT: i == 0
//   DTOR: i == 1
//
// core.exception.AssertError@source\app.d(24): Assertion failure



Confirm. Also failed.

FAIL: Destructor S, possible not called.
WANTED: Wanted to call S.~this().
PURPOSE: smart-pointer. std.typecons.Unique!S for auto close handle.
DMD: DMD32 D Compiler v2.101.0-dirty, Windows 10, x64
DMD: LDC 1.30, Windows 10, x64

--

Reply via email to