Skip to content

Bound check is incorrectly removed in jit #130216

Closed

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

Activity

  1. self-assigned this
    on Jul 5, 2026
  2. added this to the 11.0.0 milestone on Jul 5, 2026
  3. added
    area-CodeGen-coreclr
    on Jul 5, 2026
  4. dotnet-policy-service commented on Jul 5, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  5. MihuBot commented on Jul 5, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  6. locked and limited conversation to collaborators on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions