+// Compiler options: -unsafe
+
//
// Tests unsafe operators. address-of, dereference, member access
//
return 105;
return 0;
}
+
+ static int TestPtrArithmetic ()
+ {
+ char [] array = new char [10];
+ char *pb;
+
+ array [5] = 'j';
+ fixed (char *pa = array){
+ pb = pa + 1;
+
+
+ //
+ // This one tests pointer element access
+ //
+ if (pa [5] != 'j')
+ return 199;
+
+ Console.WriteLine ("V: " + (pb - pa));
+ if ((pb - pa) != 1)
+ return 200;
+
+ pb++;
+
+ if (pb == pa)
+ return 201;
+ if (pb < pa)
+ return 202;
+ if (pa > pb)
+ return 203;
+ if (pa >= pb)
+ return 204;
+ if (pb <= pa)
+ return 205;
+ pb = pb - 2;
+ if (pb != pa){
+ Console.WriteLine ("VV: " + (pb - pa));
+ return 206;
+ }
+ }
+
+ return 0;
+ }
+
+ static int TestMultiple ()
+ {
+ char [] array = new char [10];
+ int count = 0;
+
+ fixed (char *pa = array, pb = array){
+ count++;
+ }
+ if (count != 1)
+ return 300;
+ return 0;
+ }
static int Main ()
{
if ((v = TestPtrAssign ()) != 0)
return v;
+
+ if ((v = TestPtrArithmetic ()) != 0)
+ return v;
+
+ if ((v = TestMultiple ()) != 0)
+ return v;
Console.WriteLine ("Ok");
return 0;