1 // Compiler options: -unsafe
4 // Tests unsafe operators. address-of, dereference, member access
14 static int TestDereference ()
35 static int TestPtrAdd ()
37 int [] a = new int [10];
40 for (i = 0; i < 10; i++)
44 fixed (int *b = &a [0]){
47 for (i = 0; i < 10; i++){
59 static double d = 1.2;
60 static float f = 1.3F;
63 static int TestPtrAssign ()
70 fixed (char *cc = &c){
74 fixed (long *ll = &l){
78 fixed (double *dd = &d){
82 fixed (float *ff = &f){
86 fixed (short *ss = &s){
105 static int TestPtrArithmetic ()
107 char [] array = new char [10];
111 fixed (char *pa = array){
116 // This one tests pointer element access
121 Console.WriteLine ("V: " + (pb - pa));
139 Console.WriteLine ("VV: " + (pb - pa));
147 static int TestMultiple ()
149 char [] array = new char [10];
152 fixed (char *pa = array, pb = array){
164 if ((v = TestDereference ()) != 0)
167 if ((v = TestPtrAdd ()) != 0)
170 if ((v = TestPtrAssign ()) != 0)
173 if ((v = TestPtrArithmetic ()) != 0)
176 if ((v = TestMultiple ()) != 0)
179 Console.WriteLine ("Ok");