Spurious "The operation overflows at compile time in checked mode" - by stobies

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 361823 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 8/14/2008 6:01:14 AM
Access Restriction Public


For the following program, the "Intellisense Compiler" (then one that produces the squigglies in the IDE) reports a spurious error message "The operation overflows at compile time in checked mode":

class Program {

  static void Main(string[] args)
    ulong x = ulong.MaxValue - 2; // <- spurious error message here

Sign in to post a comment.
Posted by Manuel Feller on 12/9/2011 at 5:58 AM
Found a "Solution" for me:

long __testValue = n * 1073741824L;

Posted by Manuel Feller on 12/9/2011 at 5:51 AM

I need to "calculate" n GB in Bytes for a Compare.
What is the way Micosoft would recommend to code until

long __testValue = n * 1024 * 1024 * 1024;

will work in VS2010 Ultimate with SP1 for this Task?

I tried

long __testValue = n * 1073741824;

but this also does not work - same error...
Posted by SWDProgrammer on 4/11/2011 at 8:35 AM
This, or in my case, or a very similar problem exists in VS 2010

it is apparent that the long can hold the value, but overflows doing the math
15 * 60 * 1000 * 10000 = 9000000000

class Program
        static void Main(string[] args)
            long test = 9000000000;
            // intellisense reports that 'The operation overflows at compile time in checked mode' on the following line
            long ticks = 15 * 60 * 1000 * 10000;
            TimeSpan span = new TimeSpan(test);
            Console.WriteLine("Minutes = {0}", span.TotalMinutes);
Posted by jjhii on 1/20/2010 at 6:44 AM
If I open the VS 2008 all updates applied as of 2010/01/20 I get the squiggly line under the following code with the error messages in the error list "The operation overflows at compile time in checked mode" but if I do a rebuild the squiggly line is removed. Sort of annoying...

internal UInt32 PackedValues;
PackedValues &= UInt32.MaxValue - 0x1;

So it may not be as fixed as implied by the status.
Posted by Microsoft on 11/16/2008 at 5:45 PM

I wanted to let you know that we've released a public hotfix that should address the issue you're running into. You can get details about it here: http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/30/hotfix-for-vs2008-sp1-available.aspx.

Feel free to shoot me an email or contact me directly if you have any questions or comments.

DJ Park
Posted by Microsoft on 8/14/2008 at 7:30 PM
We were able to reproduce the issue you are seeing. We are escalating this bug to the product unit who works on that specific feature area. The product team will review this issue and make a decision on whether they will fix it or not for the next release