Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Fixed Help for as Fixed


3
0
Sign in
to vote
Type: Bug
ID: 361823
Opened: 8/14/2008 6:01:14 AM
Access Restriction: Public
0
Workaround(s)
view
4
User(s) can reproduce this bug

Description

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
}

}
Details
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;

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

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
stobies,

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.

Thanks!
DJ Park
C# IDE PM
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
Sign in to post a workaround.