Thread overview
[Issue 14650] Destructors are not called on global variables
Jun 04, 2015
Denis Shelomovskij
Dec 08, 2017
anonymous4
Jan 06, 2018
Jonathan M Davis
Dec 27, 2018
RazvanN
Dec 17, 2022
Iain Buclaw
June 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14650

--- Comment #1 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
In case this is an expected behavior (as written in issue 6437, comment 3), please provide reasons and link to documentation.

--
December 07, 2017
https://issues.dlang.org/show_bug.cgi?id=14650

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@erdani.com
           Assignee|nobody@puremagic.com        |greensunny12@gmail.com

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
Destructors are not called on function static objects, either. Seb, can you please check whether the language reference specifies that? Thanks!

--
December 08, 2017
https://issues.dlang.org/show_bug.cgi?id=14650

--- Comment #3 from anonymous4 <dfj1esp02@sneakemail.com> ---
Well, it will have the same problems as static constructors.

--
January 06, 2018
https://issues.dlang.org/show_bug.cgi?id=14650

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #4 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
Yeah, I just tested this after a discussion static variables and their liftemos on D.Learn

-------------------
import std.stdio;

struct S
{
    this(string foo)
    {
        _foo = foo;
    }

    ~this()
    {
        writefln("%s destroyed", _foo);
    }

    string _foo;
}

void main()
{
    static mainStatic = S("main");
    auto s = S("local");
    f();
}

void f()
{
    static fStatic = S("f");
}
-------------------

It just prints out

local destroyed

The variables for the static destructors are never called.

--
January 06, 2018
https://issues.dlang.org/show_bug.cgi?id=14650

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Not calling destructors of thread-local variables at the end of the program could potentially be considered expected behavior.

But not calling them at the end of thread termination is a big problem. As D gets closer to reference counting, sane destruction calls are going to become more and more important.

--
December 26, 2018
https://issues.dlang.org/show_bug.cgi?id=14650

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|greensunny12@gmail.com      |razvan.nitu1305@gmail.com

--
December 27, 2018
https://issues.dlang.org/show_bug.cgi?id=14650

--- Comment #6 from RazvanN <razvan.nitu1305@gmail.com> ---
PR: https://github.com/dlang/dmd/pull/9151

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14650

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--