November 10, 2018
https://issues.dlang.org/show_bug.cgi?id=19386

--- Comment #1 from Jesse Bruce <jesse.bruce@economicmodeling.com> ---
Moving object creation outside of the if statement works as intended.

struct Thing
{
    this(int* i) { ptr = i; (*ptr)++; }
    ~this() { (*ptr)--; }
    T opCast(T:bool)() { return false; }
    int* ptr;
}

Thing makeThing(int* p)
{
    return Thing(p);
}

void main()
{
    int i;
    {
        auto t = makeThing(&i);
        if(t)
        {
            import std.stdio;
            writeln("hello?");
        }
    }
    assert(i == 0);
}

Observed output:

--
May 22, 2019
https://issues.dlang.org/show_bug.cgi?id=19386

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #9830 "Fix issue 19386 - Destructor not called when constructed inside if condition" was merged into stable:

- 9d4f5555118670ef68416a0d13108e3cdcf13271 by سليمان السهمي  (Suleyman Sahmi):
  Fix issue 19386 - Destructor not called when constructed inside if condition
  This happens when the if condition evaluates to false at runtime

https://github.com/dlang/dmd/pull/9830

--