Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ee0bc0d176
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (38 sloc) 0.804 kb
using System;
using System.Runtime.InteropServices;
public class Z {
~Z() {
Console.WriteLine("Hello, world!");
}
}
[StructLayout(LayoutKind.Explicit)]
public struct X {
[FieldOffset(0)] public short a;
[FieldOffset(2)] public Z z; // Unaligned reference
}
class Y {
static X test() {
X x = new X();
x.z = new Z();
return x;
}
static void test2(X x) {
Console.WriteLine("Object: " + x);
}
static void Inner () {
X t1 = test();
System.GC.Collect();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
test2(t1);
}
static int Main() {
try {
Inner ();
} catch (TypeLoadException e) {
Console.WriteLine ("got correct exception: {0}", e);
return 0;
}
return 1;
}
}
Jump to Line
Something went wrong with that request. Please try again.