Alex Rivera | Logout

If statement weirdness in Visual Studio 2008

Asked 2009-10-22T08:44:48.573
11

I've come across a problem so strange, that I've recorded my session because I didn't think anyone would belive me.

I came across a bug that seems to be at very fundamental level. This is a single threaded application and all im doing is evaluating a boolean.

The boolean equals false, however, the if statement is executing as if it were true...sort of. You'll see what I mean. I've cleaned the solution and rebuilt many times. No idea whats going on.

I'd love some explanations please.

http://www.youtube.com/watch?v=ope9kxEyt4g

Edit
Report

1 Answer

0

I had exactly the same problem week ago. Also have VS2008, latest SP. WinForms application. The value was false but if body was always executed. I was doing same investigations as in your video. Here is my piece of code:

 if (CurrentFileFormatVersion > int.Parse(metaInfo.SimulationFileVersion))
     throw new SimulationFormatException(ws, ss);

Running without debugger compiled as 'Release' was fine. Try it.

I suppose there is a bug in VS2008 debugger. Somehow reproducible with 'if' and 'throw' keywords.

EDIT: the 'executed' word above is wrong one of course. 'Stepped in but not executed' must be used instead.

answered 2009-10-22T09:02:38.863

Your Answer