[Mono-devel-list] possible bug in static constructor evaluation order

Paolo Molaro lupus at ximian.com
Mon May 5 06:56:11 EDT 2003

On 05/04/03 Michal Moskal wrote:
> Could anyone confirm this with current CVS (I cannot get it to run)?

Please, can you post details about the issue you have in getting cvs to
run? Thanks.

> #v+
> class A {
>   static A() { System.Console.WriteLine("A"); }
>   public static void f() {}
> }
> class B {
>   static B() { System.Console.WriteLine("B"); A.f(); }
>   public static void f() {}
> }
> class M {
>   public static void Main() { B.f(); }
> }
> #v-
> produces:
> A
> B

This is caused by inlining: there are also other issues with static
initializers ordering both in the current release and in the cvs
version. They will be addressed after the next release (due real soon
now) when we'll be able to drop the old jit.
You'll find, though, that the new jit doesn't use inlining by default,
so your test will execute correctly with it if you don't explicitly
enable it.


lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

More information about the Mono-devel-list mailing list