提交 dfa517d4 编写于 作者: M Michal Strehovský 提交者: GitHub

Add test coverage for casting to pointers (dotnet/coreclr#26698)

I was fixing a customer-reported bug related to this in .NET Native and decided to check whether there's any test coverage for this in CoreCLR. There isn't, so adding a test.

Commit migrated from https://github.com/dotnet/coreclr/commit/3f8d0e92ada4f1bc37e93c644054acf0a43692cf
上级 32a5dd59
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
.assembly castclasspointer { }
.assembly extern mscorlib { }
.method public static int32 Main()
{
.entrypoint
ldnull
castclass void*
pop
newobj instance void [mscorlib]System.Object::.ctor()
isinst void*
brtrue BAD
.try
{
newobj instance void [mscorlib]System.Object::.ctor()
castclass void*
pop
leave BAD
}
catch [mscorlib]System.InvalidCastException
{
pop
leave OK
}
BAD:
ldc.i4 1
ret
OK:
ldc.i4 100
ret
}
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
<OutputType>Exe</OutputType>
<CLRTestKind>BuildAndRun</CLRTestKind>
</PropertyGroup>
<ItemGroup>
<Compile Include="castclasspointer.il" />
</ItemGroup>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册