bugDotGNU Portable.NET - Bugs: bug #22866, Class constructor is not called...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22866: Class constructor is not called correctly when accessing a class variable

Submitter:  None
Submitted:  Mon 07 Apr 2008 12:57:30 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Sun 21 Sep 2008 01:42:28 PM UTC, comment #1: 

ECMA specs say that the static constructor has to be executed before a static member is accessed.
It doesn't explicitly say that the cctor has to be executed just before the first static member is accessed.
In pnet the cctors are executed before a function is executed that might access a static member.
This avoids emitting code in the function to check if the cctor was executed and to call it.

Klaus Treichel <ktreichel>
Group administrator
Mon 07 Apr 2008 12:57:30 PM UTC, original submission:  

using System;

class Foo {

        static public int i = 0;
}

class Bar {

        static public int j;

        static Bar () {
                j = Foo.i;
        }
}

class Bug {

        static public int Main () {
                Foo.i = 5;
if (Bar.j != 5)
return 1;

return 0;
        }
}

The above test returns 1 in PNET.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ktreichel (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-09-21 ktreichel StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code