Skip to content

Commit 741c0c8

Browse files
authored
Fix exceptions thrown by LDiv/LMod helpers (#98474)
1 parent c7253b1 commit 741c0c8

File tree

1 file changed

+3
-7
lines changed
  • src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers

1 file changed

+3
-7
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/MathHelpers.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ public static long LMod(long i, long j)
164164
{
165165
if (j == 0)
166166
return ThrowLngDivByZero();
167+
else if (j == -1 && i == long.MinValue)
168+
return ThrowLngOvf();
167169
else
168170
return RhpLMod(i, j);
169171
}
@@ -189,7 +191,7 @@ public static long LDiv(long i, long j)
189191
if (j == 0)
190192
return ThrowLngDivByZero();
191193
else if (j == -1 && i == long.MinValue)
192-
return ThrowLngArithExc();
194+
return ThrowLngOvf();
193195
else
194196
return RhpLDiv(i, j);
195197
}
@@ -205,12 +207,6 @@ private static ulong ThrowULngDivByZero()
205207
{
206208
throw new DivideByZeroException();
207209
}
208-
209-
[MethodImpl(MethodImplOptions.NoInlining)]
210-
private static long ThrowLngArithExc()
211-
{
212-
throw new ArithmeticException();
213-
}
214210
#endif // TARGET_64BIT
215211

216212
[RuntimeExport("Dbl2IntOvf")]

0 commit comments

Comments
 (0)