Skip to content

Bound check is incorrectly removed in jit #130216

Description

@EgorBo
using System.Runtime.CompilerServices;

sealed class S
{
    private static int Sink;

    static void Main()
    {
        Test(new int[6], true);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static int Test(int[] arr, bool c)
    {
        int prev = arr[5];
        int j;
        if (c)
        { 
            Sink = 1; 
            j = -5; 
        } 
        else 
        { 
            j = 3;
        }
        return prev + arr[j];                    
    }   
}

Expected:

System.IndexOutOfRangeException

Actual:

System.AccessViolationException

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions