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

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                   |                            |rg

--- Comment #1 from [email protected] ---
Modified:

extern (C) int printf(scope const char*, ...);

struct S
{
        this(int arg)
        {
                a = arg;
                printf("this(%d), this = %p\n", a, &this);
        }

    ~this()
    {
        printf("~this(%d), this = %p\n", a, &this);
    }

        int a;
}

void main()
{
        auto s = true ? S(1) : S(0);
    printf("main\n");
}

----

this(1), this = 0x7fff3b745b88
~this(1), this = 0x7fff3b745b88
main
~this(1), this = 0x7fff3b745b98

---

So there's only one dtor call for the temporary created inside of the ternary
operator and another call for the variable s at the end of main.

--

Reply via email to