www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6364] New: Static struct's destructor called on exit of function

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6364

           Summary: Static struct's destructor called on exit of function
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



22:08:18 PDT ---
import std.stdio;

void main()
{
   test();
   test();
}

struct Foo
{
   int state = 1;

   ~this()
   {
       state = 0;
   }
}

void test()
{
   static Foo foo;
   writeln(foo.state);
}


Prints:
1
0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6364




07:07:56 PST ---

To clarify: It should print 1 both times. I think the dtor should run on app
exit, since it's a static variable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6364


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code
           Platform|Other                       |All
         OS/Version|Windows                     |All



https://github.com/D-Programming-Language/dmd/pull/612

NOTE: This patch does not fix "dtor is never called on global variable" problem
(it is filed as bug 6437).
So after the patch applied, foo's dtor would never be called.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6364




09:24:52 PST ---

 https://github.com/D-Programming-Language/dmd/pull/612
 
 NOTE: This patch does not fix "dtor is never called on global variable" problem
 (it is filed as bug 6437).
 So after the patch applied, foo's dtor would never be called.
Yeah they're two different bugs, I guess. Thanks for fixing this one though! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 06 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6364


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



15:03:03 PST ---
https://github.com/D-Programming-Language/dmd/commit/04e49317d79269c2ec30217562b97eaa6f9699a7

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2012