以下代码在Visual Studio中运行发行版时提供了不同的输出,并在Visual Studio外运行发行版。我正在使用Visual Studio 2008并以.NET 3.5为目标。我也尝试过.NET 3.5 SP1。 (a)我错过了C#发生的某些细节,或者(b)JIT实际上是错误的。我怀疑的是,JIT可以去错了,但我跑出来其他possiblities的....NET JIT潜在错误?
输出在Visual Studio中运行时:
0 0,
0 1,
1 0,
1 1,
输出Visual Studio之外运行时释放:
0 2,
0 2,
1 2,
1 2,
是什么原因?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
struct IntVec
{
public int x;
public int y;
}
interface IDoSomething
{
void Do(IntVec o);
}
class DoSomething : IDoSomething
{
public void Do(IntVec o)
{
Console.WriteLine(o.x.ToString() + " " + o.y.ToString()+",");
}
}
class Program
{
static void Test(IDoSomething oDoesSomething)
{
IntVec oVec = new IntVec();
for (oVec.x = 0; oVec.x < 2; oVec.x++)
{
for (oVec.y = 0; oVec.y < 2; oVec.y++)
{
oDoesSomething.Do(oVec);
}
}
}
static void Main(string[] args)
{
Test(new DoSomething());
Console.ReadLine();
}
}
}
+1 - 这是一个多么小的问题:) –
是的 - 那怎么样:找到一个像.Net JIT一样重要的严重错误 - 恭喜! –
这似乎是在我12月9日在x86上构建的4.0框架中重新生成。我会把它传递给抖动团队。谢谢! –