There is a Pex4Fun problem that asks the user to write code that finds the sum of the array.
using System; using System.Linq; public class Program { public static int Puzzle(int[] a) { return a.Sum(); } }
Pex expects it to be able to pass {-1840512878, -2147418112} and return an invalid number 307036306, however the LINQ method, Array.Sum (), checks for overflow.
I canβt use the unverified keyword around the a.Sum () method call, because adding happens inside the method.
Is there a way to disable underflow / overflow checking with Array.Sum ()?
source share