Skip to content
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
15 changes: 12 additions & 3 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11160,10 +11160,19 @@ GenTree* Compiler::fgPropagateCommaThrow(GenTree* parent, GenTreeOp* commaThrow,
}

// Fix up the COMMA's type if needed.
if (genActualType(parent) != genActualType(commaThrow))
var_types parentType = genActualType(parent);
if (parentType != genActualType(commaThrow))
{
commaThrow->gtGetOp2()->BashToZeroConst(genActualType(parent));
commaThrow->ChangeType(genActualType(parent));
if (parentType == TYP_STRUCT)
{
return nullptr;
}

GenTree* zero = gtNewZeroConNode(parentType);
zero->SetMorphed(this);

commaThrow->gtOp2 = zero;
commaThrow->ChangeType(parentType);
}

return commaThrow;
Expand Down
29 changes: 29 additions & 0 deletions src/tests/JIT/Regression_o_2/Runtime_133862.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 Xunit;

public class Runtime_133862
{
private struct S
{
public int A;
public int B;
public int C;
public int D;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int Index(long value) => checked((int)value);

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static S Load(S[] values) => values[Index(long.MaxValue)];

[Fact]
public static void TestEntryPoint()
{
Assert.Throws<OverflowException>(() => Load(new S[4]));
}
}
Loading