Skip to content

Commit

Permalink
simplify IntPtr<->int bounds check expression (dotnet#5011)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Feb 12, 2019
1 parent 9517413 commit 591b308
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ private void InterpretStoreElement(ILOpcode opcode)
case StackValueKind.NativeInt:
{
long value = (long)indexItem.AsNativeInt();
if (value >= int.MinValue && value <= int.MaxValue)
if ((int)value != value)
throw new IndexOutOfRangeException();
index = (int)value;
}
Expand Down Expand Up @@ -2228,7 +2228,7 @@ private void InterpretStoreElement(int token)
case StackValueKind.NativeInt:
{
long value = (long)indexItem.AsNativeInt();
if (value >= int.MinValue && value <= int.MaxValue)
if ((int)value != value)
throw new IndexOutOfRangeException();
index = (int)value;
}
Expand Down Expand Up @@ -2309,7 +2309,7 @@ private void InterpretLoadElement(ILOpcode opcode)
case StackValueKind.NativeInt:
{
long value = (long)indexItem.AsNativeInt();
if (value >= int.MinValue && value <= int.MaxValue)
if ((int)value != value)
throw new IndexOutOfRangeException();
index = (int)value;
}
Expand Down Expand Up @@ -2376,7 +2376,7 @@ private void InterpretLoadElement(int token)
case StackValueKind.NativeInt:
{
long value = (long)indexItem.AsNativeInt();
if (value >= int.MinValue && value <= int.MaxValue)
if ((int)value != value)
throw new IndexOutOfRangeException();
index = (int)value;
}
Expand Down

0 comments on commit 591b308

Please sign in to comment.