New tests.
[mono.git] / mcs / tests / test-653.cs
1 // Compiler options: -unsafe \r
2 using System;\r
3 \r
4 class C\r
5 {\r
6         static unsafe int Test ()\r
7         {\r
8                 try {\r
9                         uint* i = stackalloc uint[int.MaxValue];\r
10                         uint v = 0;\r
11                         i [v] = v;\r
12                         i [0] = v;\r
13                         return 1;\r
14                 } catch (OverflowException) {\r
15                         return 0;\r
16                 }\r
17         }\r
18         \r
19         unsafe static void Test2 ()\r
20         {\r
21                 byte* b = null;\r
22                 b = b + (byte)1;\r
23                 b = b + (sbyte)1;\r
24                 b = b + (short)1;\r
25                 b = b + (int)1;\r
26                 b = b + (long)1;\r
27                 b = b + (ulong)1;\r
28         }\r
29         \r
30         unsafe static void Test2 (sbyte sb, short s, int i, long l, ulong ul)\r
31         {\r
32                 short* b = null;\r
33                 b = b + sb;\r
34                 b = b + s;\r
35                 b = b + i;\r
36                 b = b + l;\r
37                 b = b + ul;\r
38         }\r
39         \r
40         public static int Main ()\r
41         {\r
42                 Test2 ();\r
43                 Test2 (1, 2, 3, 4, 5);\r
44                 if (Test () != 0)\r
45                         return 1;\r
46                         \r
47                 Console.WriteLine ("OK");\r
48                 return 0;\r
49         }\r
50 }\r