tags:

views:

225

answers:

2
uint x = uint.MaxValue - 100;

The above line causes visual studio to report "The operation overflows at compile time in checked mode"

I'm obviously missing something. Any ideas what?

+1  A: 

It may be implicity converting the uint.MaxValue to signed because you are subtracting a constant which is implicity signed. Try:

uint x = uint.MaxValue - 100U;
JoelFan
This does not work either. Seems to be a bug in the refactoring compiler.
SDX2000
Nope, same result
Frustrating Developments
+4  A: 

Hi, this error is being reported by the C# frontend used by the VS refactoring tool. When you go ahead and compile it using the actual compiler the error disappears!

SDX2000
That would explain why it seems happy sometimes and then (often after a pause) the "error" pops up.
Frustrating Developments
Yeah, but why? What's the diff between the actual compiler and the 'front-end'? Slightly worrying.
Henk Holterman
Well, most likely the VS refactoring compiler is a specialized compiler built for speed and code transformation hence could be somewhat different from the main compiler.
SDX2000
Ok one more thing the VS refactoring compiler is able to compile smaller subsets of all the files present in a project which might suggest its able to work on incomplete information upto a certain extent.
SDX2000