[Issue 7325] New: Static / instance destruction order

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 20 08:16:10 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7325

           Summary: Static / instance destruction order
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: renezwanenburg at gmail.com


--- Comment #0 from Rene Zwanenburg <renezwanenburg at gmail.com> 2012-01-20 08:16:08 PST ---
We have a situation where a class has a static associative array member, which
is accessed in the destructor. 

If there are still instances left of this class during program shutdown, the GC
deletes them and calls the destructor. At this point the static member appears
to have been deleted, as any operations on the array cause the program to
crash. 

The aa is non-null, so checking for a null pointer doesn't work. As a
workaround, it's possible to add a static destructor to the class which sets
the aa to null, and check for this in the non-static destructor. 

This is less than ideal, so it would be nice if it's possible to change the
destruction order: First all class instances, then the static data.

-- 
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