Bug Details: Arithmetic operation resulted in an overflow with Int32.

Here’s a bug that Microsoft knows about, but has postponed until “VNext”.

This code will blow up in .NET:

public class FDBK23539
{
  public static void Calculate()
  {
   checked
   {
    int ii = int.MinValue;
    int a = ii – ii;
    int b = ii – int.MinValue; //Arithmetic operation resulted in an overflow.
   }
  }
  public static int Main(string[] args)
  {
   System.Console.WriteLine(System.Environment.Version);
   Calculate();
   return 0;
  }
}

Look at the code in the checked() function:

int ii = Int32.MinValue;
int a = ii – ii;
int b = ii – Int32.MinValue;

The values of a and b should be the same and an overflow exception should not be thrown for the b operation.

I loved the responses from MS:
Because the scenario is corner-case and given where we are in the cycle, I’m going to track this as an issue for consideration in VNext. We do appreciate the issue, we’re really just ensuring we’re looking at critical issues, since we want to get this product to you ASAP.

It’s too early on a Monday morning to be reading this.