blob: c566eda83ebebb4fe1db5d33339b98dd8bc54f52 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Runtime.CompilerServices;
public class CMyException : System.Exception
{
}
public class CTest
{
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private static void UseByte(byte x)
{
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private static unsafe void CheckDoubleAlignment(double* p)
{
if (((int)p % sizeof(double)) != 0)
throw new CMyException();
}
private static void DoGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(100);
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private static unsafe void TestArrays1(int n, double d)
{
int i, j;
double[][] a = new double[n][];
byte[][] b = new byte[n][];
for (i = 0; i < n; i++)
{
a[i] = new double[i + 1];
fixed (double* p = &a[i][0])
{
CheckDoubleAlignment(p);
}
b[i] = new byte[i + 1];
}
for (i = 0; i < n; i++)
{
for (j = 1; j <= i; j++)
{
a[i][j] += a[i][j - 1];
b[i][j] = 48;
}
}
for (i = 0; i < n; i++)
{
UseByte(b[i][i]);
UseByte((byte)a[i][i]);
}
}
public static int Main()
{
try
{
TestArrays1(100, 2.0);
}
catch (CMyException)
{
Console.WriteLine("FAILED");
return 101;
}
Console.WriteLine("PASSED");
return 100;
}
}
|