Thread overview
[Issue 19218] object.destroy should check for classes for static arrays
Jul 14, 2019
karita
Feb 15, 2020
Dlang Bot
Feb 15, 2020
Dlang Bot
July 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19218

karita <shigekikarita@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shigekikarita@gmail.com

--- Comment #1 from karita <shigekikarita@gmail.com> ---
I agree with you. I made a unittest for checking this

---
unittest
{
    struct S
    {
        static dtorCount = 0;
        ~this() { ++dtorCount; }
    }

    class C
    {
        static dtorCount = 0;
        ~this() { ++dtorCount; }
    }

    struct A(T)
    {
        T[3] a;
        alias a this;
    }

    auto as = new A!S;
    destroy(as);
    auto ac = new A!C;
    destroy(as);
    assert(S.dtorCount == 3); // 0
    assert(C.dtorCount == 3); // 0
}

--
February 15, 2020
https://issues.dlang.org/show_bug.cgi?id=19218

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg

--- Comment #2 from moonlightsentinel@disroot.org ---
(In reply to karita from comment #1)
> I agree with you. I made a unittest for checking this [...]

That unittest is wrong because it destroys the >pointer< to an A instead of the instance (`destroy` takes its arguments by ref).

--
February 15, 2020
https://issues.dlang.org/show_bug.cgi?id=19218

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@MoonlightSentinel created dlang/druntime pull request #2942 "Fix Issue 19218 - object.destroy should check for classes for static …" fixing this issue:

- Fix Issue 19218 - object.destroy should check for classes for static arrays

https://github.com/dlang/druntime/pull/2942

--
February 15, 2020
https://issues.dlang.org/show_bug.cgi?id=19218

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

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

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/druntime pull request #2942 "Fix Issue 19218 - object.destroy should check for classes for static …" was merged into master:

- 453b320bf13239faf73ff969d0095187ac9f0ecc by MoonlightSentinel:
  Fix Issue 19218 - object.destroy should check for classes for static arrays

https://github.com/dlang/druntime/pull/2942

--