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) constant-NaN Math.Min/Max folding drops the other argument's side effects #133718
Expected:IndexOutOfRangeException (correct) — a[5] on a length-1 array must throw before Math.Min returns. Actual:NO EXCEPTION, result=NaN — the array load, including its bounds check, is discarded.
Notes:
run.ps1 -Cs repro.cs (csc -optimize+, Checked corerun x64). Compiling with -optimize- prints the correct IndexOutOfRangeException, so it is purely the optimized-JIT path.
src\coreclr\jit\gentree.cpp in gtNewSimdMinMaxNode: the isNaN shortcut does return cnsNode; (non-Number) / return otherNode; (Number) with no gtExtractSideEffList/COMMA for the discarded operand.
Only on the non-AVX10v2 xarch path (the AVX10v2 branch is taken earlier and is unaffected). Same shape works for MathF.Min, Math.Max, and the MinNumber/MaxNumber variants (drop the other operand there).
Activity
dotnet-policy-service commentedon Sep 11, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
EgorBo commentedon Sep 18, 2026
Affected SDK versions:
JIT: Preserve SIMD operand evaluation and ordering (#133776)