You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) Assert (constIndexOffset % elemSize) == 0 in GenTreeArrAddr::ParseArrayAddress for 3-byte element arrays #134192
ParseArrayAddressWork folds the constant index component with wrapping native arithmetic and then asserts the accumulated offset is divisible by the element size, which only holds for element sizes dividing 2^64.
Minimal Repro
usingSystem;usingSystem.Runtime.CompilerServices;usingSystem.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,Pack=1)]publicstructS3{publicbyteA,B,C;}publicclassProgram{[MethodImpl(MethodImplOptions.NoInlining)]publicstaticbyteGet(S3[]a,longx)=>a[x+6148914691236517206L].A;publicstaticvoidMain(){vara=newS3[4];a[0].A=42;Console.WriteLine(Get(a,-6148914691236517206L));// index 0}}
Expected
42
Actual
Assert failure: Assertion failed '(constIndexOffset % elemSize) == 0' in 'Program:Get(S3[],long):byte'
during 'Do value numbering' (IL size 24; hash 0x6f6c0c6c; FullOpts)
File: src\coreclr\jit\gentree.cpp:22035
Notes
Checked x64. The index expression sums to exactly 0 at the language level — no overflow occurs in the source; the wrap (0x5555555555555556 * 3 → 2) happens only inside the JIT's own address re-association.
Released .NET 10.0.12 prints 42, i.e. the assert is Checked-only. Whether the Release JIT silently truncates the remainder when forming the element VN was not verified and needs separate triage.
Activity
dotnet-policy-service commentedon Sep 18, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.