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

Submitted by:  None
Submitted on:  Mon 07 Apr 2008 12:57:30 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned 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>
Project 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

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 21 Sep 2008 01:42:28 PM UTCktreichelStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1