Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-401.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bf237ea3cabe09567b1a98ebefb3432863dcfb58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Compiler options: -unsafe

//
// This test excercises stackalloc, some pointer arithmetic,
// and dereferences
//
using System;
unsafe class X {
	public static int Main ()
	{
		char *ptr = stackalloc char [10];
	        char *cptr = ptr;
		int i;
		long l = 0;
		ulong ul = 0;
		byte b = 0;
		
		for (i = 0; i < 10; i++)
			ptr [i] = (char) (i + 10);

		for (i = 0; i < 10; i++){
			if (*ptr != (char) (i + 10))
				return 200 + i;
			ptr++;
		}


		// Now test index access with longs
		if (cptr [l] != 10){
			return 1;
		}
		if (cptr [ul] != 10)
			return 2;
		if (cptr [b] != 10)
			return 3;

		//
		// Try to compile non-int values
		//
		byte* bptr = (byte*) 5;
                ushort us = 3;
                byte* ret = (byte*) (bptr + us);
			
		Console.WriteLine ("Ok");
		return 0;
	}
}