By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,219 Members | 1,736 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,219 IT Pros & Developers. It's quick & easy.

BUG: Incorrect / inconsistent program behaviour when the "Remove Integer Overflow Checks" option is enabled

P: n/a
This is a worrying bug, and indicates a potential problem in the Framework
CLR. This bug affected a project I was working on, which behaved differently
when run from the Visual Studio IDE than when run by double clicking on the
project's EXE file. The problem can be replicated easily:

Create a new project in Visual Studio 2003 and add the following code.
Module Main
Sub Main()
Dim xmlDoc As New System.Xml.XmlDocument
xmlDoc.AppendChild(xmlDoc.CreateElement("Root"))
Dim o, n As Object
Dim count As Integer
For Each o In xmlDoc.ChildNodes
For n = 0 To 9
count += 1
Next
Next
System.Windows.Forms.MessageBox.Show("Count: " & count)
End Sub
End Module
IMPORTANT: To replicate the bug, you must

(1) Set the project compile mode to "Release"
(2) Enable the following option: Project Configuration Properties /
Optimisations / "Remove Integer Overflow Checks"

Finally, run the program from the Visual Studio IDE. The expected message,
"Count: 10", is displayed. Now run the program from it's EXE file via
Windows Explorer. A message, "Count: 1" is displayed, which is incorrect.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ralph,

Interesting, that does indeed look like some kind of JIT compiler bug.

FYI, changing the loop variable n to an Integer fixes the problem. Why
did you have it declared as Object anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #2

P: n/a
I know it fixes it, but I wanted to show the problem. Actually, changing the
code in almost any way fixes the problem.

It's a rather worrying thought that this kind arbitrary JIT compiler problem
might affect anyone's code.

So, there was no specific reason for the Object declaration, other than the
fact that I wanted to provide a simple example that did not break the
problem. (In my shipping code I used a For / Each for the inner loop, not an
object).
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Ralph,

Interesting, that does indeed look like some kind of JIT compiler bug.

FYI, changing the loop variable n to an Integer fixes the problem. Why
did you have it declared as Object anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 20 '05 #3

P: n/a
Ralph,
I know it fixes it, but I wanted to show the problem. Actually, changing the
code in almost any way fixes the problem.
OK, fine. FWIW, the bug seems to be fixed in Whidbey.

It's a rather worrying thought that this kind arbitrary JIT compiler problem
might affect anyone's code.


Well, there will always be bugs.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.