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

test-653.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1e930bb51e5fdf0fde54c9ea58e9d8b7c203bd2 (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
50
// Compiler options: -unsafe 
using System;

class C
{
	static unsafe int Test ()
	{
		try {
			uint* i = stackalloc uint[int.MaxValue];
			uint v = 0;
			i [v] = v;
			i [0] = v;
			return 1;
		} catch (OverflowException) {
			return 0;
		}
	}
	
	unsafe static void Test2 ()
	{
		byte* b = null;
		b = b + (byte)1;
		b = b + (sbyte)1;
		b = b + (short)1;
		b = b + (int)1;
		b = b + (long)1;
		b = b + (ulong)1;
	}
	
	unsafe static void Test2 (sbyte sb, short s, int i, long l, ulong ul)
	{
		short* b = null;
		b = b + sb;
		b = b + s;
		b = b + i;
		b = b + l;
		b = b + ul;
	}
	
	public static int Main ()
	{
		Test2 ();
		Test2 (1, 2, 3, 4, 5);
		if (Test () != 0)
			return 1;
			
		Console.WriteLine ("OK");
		return 0;
	}
}