In class/Microsoft.Build.Tasks:
[mcs.git] / tests / test-740.cs
blob8fabcd48bfe88b5c3e46cf885decc37260ef9224
1 // Compiler options: -unsafe
3 using System;
4 using System.Runtime.InteropServices;
6 class FixedTest
8 [StructLayout (LayoutKind.Explicit)]
9 public unsafe struct Value
11 [FieldOffset (0)]
12 public void* p;
13 [FieldOffset (0)]
14 public double n;
15 [FieldOffset (0)]
16 public long i;
17 [FieldOffset (0)]
18 public bool b;
21 [StructLayout (LayoutKind.Sequential, Pack = 4)]
22 public unsafe struct TValue
24 public Value value;
26 public TValue (long x)
28 value = new Value ();
29 value.i = x;
32 public override string ToString ()
34 return value.i.ToString ();
38 public static unsafe int Main ()
40 TValue[] values = new TValue[10];
41 values[0] = new TValue (0L);
42 values[1] = new TValue (1000L);
43 values[2] = new TValue (1L);
44 Console.WriteLine ("values: {0} {1} {2}", values[0], values[1], values[2]);
45 fixed (TValue* vals = values) {
46 Console.WriteLine ("fixed: {0} {1} {2}", vals[0], vals[1], vals[2]);
47 if (vals[0].ToString () != "0")
48 return 1;
50 if (vals[1].ToString() != "1000")
51 return 2;
53 if (vals[2].ToString() != "1")
54 return 3;
57 Console.WriteLine ("ok");
58 return 0;