-// Compiler options: -unsafe
+using System;
-unsafe struct S
+class Foo
{
- public short nData;
- public fixed int Data [1];
-}
+ static int Main ()
+ {
+ if (Bar (1))
+ return 1;
-unsafe struct S2
-{
- public uint Header;
- public fixed byte Data [5];
+ if (!Bar (IntPtr.Zero))
+ return 2;
- public void Test ()
- {
- fixed (byte* bP = Data) {
- S* p = (S*) bP;
- p = (S*) (p->Data + p->nData);
- }
+ return 0;
}
- public static void Main ()
+ static bool Bar<T> (T val) where T : struct
{
- new S2 ().Test ();
+ return val is IntPtr;
}
}
-