[Issue 6364] New: Static struct's destructor called on exit of function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 22 22:08:22 PDT 2011


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 at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-07-22 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: -------


More information about the Digitalmars-d-bugs mailing list