[Mono-list] gmcs: generates invalid IL

Alan Jenkins sourcejedi@phonecoop.coop
Tue, 03 Aug 2004 15:41:36 +0100


I know this might not be much good to anyone, given that gmcs is still 
in alpha - but it might be useful as a small test case.
I notice the $PRIVATE$ field in the Inner struct (whatever that is) in 
the dissasembly seems to violate the size of 0 bytes.

c# source:

public class Generic<T> {
    public struct Inner {
    }
}    

public class Test {
    public static void Main ()
    {
        Generic<int>.Inner inner;
    }
}

mono error:

** ERROR **: unknown operator: stobj
aborting...
Aborted

monodis output (some comments removed):

.assembly extern mscorlib
{
  .ver 2:0:3600:0
}
.assembly 'LookupTable2'
{
  .hash algorithm 0x00008004
  .ver  0:0:0:0
}
.module LookupTable2.exe


  .class public auto ansi beforefieldinit 'Generic!1'<T>
        extends [mscorlib]System.Object
  {

    // method Generic!1::instance default void .ctor ()
    .method public hidebysig  specialname  rtspecialname
           instance default void .ctor ()  cil managed
    {
        .maxstack 8
        IL_0000:  ldarg.0
        IL_0001:  call instance void valuetype 
[mscorlib]System.Object::.ctor()
        IL_0006:  ret
    }

  .class nested public sequential ansi sealed beforefieldinit Inner<T>
        extends [mscorlib]System.ValueType
  {
    .pack 0
    .size 0
    .field  private   unsigned int8 $PRIVATE$

  } // end of class Inner

  } // end of class Generic!1

  .class public auto ansi beforefieldinit Test
        extends [mscorlib]System.Object
  {

    //method Test::instance default void .ctor ()
    .method public hidebysig  specialname  rtspecialname
           instance default void .ctor ()  cil managed
    {
        .maxstack 8
        IL_0000:  ldarg.0
        IL_0001:  call instance void valuetype 
[mscorlib]System.Object::.ctor()
        IL_0006:  ret
    }

// method Test::default void Main ()
    .method public static  hidebysig
           default void Main ()  cil managed
    {
        .entrypoint
        .maxstack 0
        .locals init (
                valuetype 'Generic!1/Inner'<int32>      V_0)
        IL_0000:  ret
    }

  } // end of class Test