blob: a4bdc414e60a42db7c58a836bb1cbbe866085f65 (
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
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// compile with: csc /o+ <filename.cs>
using System;
using System.Runtime.CompilerServices;
public class Bug426480
{
public static int s_i = 0;
public static bool first_time_through = true;
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void foo()
{
int a = s_i;
if (first_time_through)
{
first_time_through = false;
s_i = 5 / s_i;
}
s_i += a;
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void bar()
{
foo();
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static int Main(String[] args)
{
try
{
// saves the caller context
foo();
}
catch (DivideByZeroException)
{
// eat the expected exception
}
try
{
//uses stale context in epilogue checking
bar();
}
catch (Exception e)
{
Console.WriteLine("Unexpected Exception!");
Console.WriteLine(e);
Console.WriteLine();
Console.WriteLine("Test Failed");
return 1;
}
Console.WriteLine("Test Passed");
return 100;
}
}
|