Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: remove incorrect type deduction for an Unsafe.As case #93694

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18752,10 +18752,12 @@ CORINFO_CLASS_HANDLE Compiler::gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldH
{
JITDUMP("Field's current class not available\n");
}

return fieldClass;
}
}

return fieldClass;
return NO_CLASS_HANDLE;
}

//------------------------------------------------------------------------
Expand Down
42 changes: 42 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_93650/Runtime_93650.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.CompilerServices;
using System.Text;
using Xunit;

public struct Holder
{
internal StringBuilder.AppendInterpolatedStringHandler _h;
public Holder() => _h = new(0, 0, new());

internal StringBuilder GetBuilder() => Unsafe.As<StringBuilder.AppendInterpolatedStringHandler, StringBuilder>(ref _h);
}

public static class Runtime_93650
{
static int N = 1;

[Fact]
public static int Problem()
{
var sb = new Holder();
for (int i = 0; i < N; i++)
{
var s = Bind(ref sb);
if (s.Length != 0)
{
Console.WriteLine("FAILED: StringBuilder.ToString() returned: " + s);
return -1;
}
}

return 100;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static string Bind(ref Holder parameters) => GetString(parameters.GetBuilder());

public static string GetString(StringBuilder sb) => sb.ToString();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading