www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1209] New: static class constructor not called

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

           Summary: static class constructor not called
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: leo.dahlmann gmail.com


In the following code the static constructor of Foo is not called and thus
the assert in main fails.

If you replace this() with static this() it works.

I think, because this() is inside a static block, it should be static.


uint x = 0;

class Foo
{
        static
        {
                this()
                {
                        x++;
                }
        }
}

void main()
{
        assert(x == 1);
}


-- 
May 01 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1209


thomas-dloop kuehne.cn changed:

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





http://www.digitalmars.com/d/class.html :






-- 
May 20 2007