Skip to content

Commit e3f2f07

Browse files
jakobbotschmatouskozak
authored andcommitted
JIT: Add a test around range check overflow (dotnet#100820)
Add a test that fails without the overflow check in range check.
1 parent 52f4831 commit e3f2f07

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
using Xunit;
4+
5+
public class RangeCheck_Overflow
6+
{
7+
[Fact]
8+
public static int TestEntryPoint()
9+
{
10+
return Overflow([10, 0, 20, 0, 30, 0, 40]);
11+
}
12+
13+
[MethodImpl(MethodImplOptions.NoInlining)]
14+
private static int Overflow(Span<byte> a)
15+
{
16+
// CHECK: CORINFO_HELP_RNGCHKFAIL
17+
18+
int sum = 0;
19+
for (int i = 0; i < a.Length; i += 2)
20+
{
21+
sum += a[i];
22+
}
23+
24+
return sum;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<DebugType>None</DebugType>
4+
<Optimize>True</Optimize>
5+
<!-- Needed for CLRTestEnvironmentVariable -->
6+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<Compile Include="$(MSBuildProjectName).cs">
10+
<HasDisasmCheck>true</HasDisasmCheck>
11+
</Compile>
12+
13+
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" />
14+
<CLRTestEnvironmentVariable Include="DOTNET_JITMinOpts" Value="0" />
15+
</ItemGroup>
16+
</Project>

0 commit comments

Comments
 (0)