Skip to content

JIT: Redundant bound check #111027

@EgorBo

Description

@EgorBo
static bool ParseIP(string s)
{
    if (s.Length > 15)
    {
        return false;
    }

    Span<ushort> value = stackalloc ushort[16];
    value[s.Length] = '.';
    Consume(value);
    return true;
}


[MethodImpl(MethodImplOptions.NoInlining)]
static void Consume<T>(Span<T> _)
{
}

Currently, value[s.Length] = '.'; line produces a bound check while it shouldn't.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions