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) Loop hoisting moves a throwing division above a bounds check, so the wrong exception is raised #133585
arr has length 1 and idx is 5, so the very first statement of the first iteration must fault
before a / b is ever evaluated.
Expected
IndexOutOfRangeException
Actual
DivideByZeroException
Also reproduces on the Release runner with no environment variables set at all. DOTNET_JitDoLoopHoisting=0 and DOTNET_JITMinOpts=1 both print the correct IndexOutOfRangeException.
The invariant arr[idx] bounds check is not hoistable, but because it is loop-invariant it does
not close loop hoisting's exception-ordering barrier, so the invariant a / b is hoisted into the
preheader and executes ahead of it.
Platform
Windows x64, .NET 11 (dotnet/runtime main @ a0b86b1, Checked and Release builds). No special
env vars or CPU features required.
Activity
dotnet-policy-service commentedon Sep 10, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Sep 10, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
EgorBo commentedon Sep 18, 2026
Affected SDK versions:
JIT: Preserve exception order in loop hoisting (#133642)