【发布时间】:2016-08-03 22:57:49
【问题描述】:
考虑:
using System;
public class Test
{
enum State : sbyte { OK = 0, BUG = -1 }
static void Main(string[] args)
{
var s = new State[1, 1];
s[0, 0] = State.BUG;
State a = s[0, 0];
Console.WriteLine(a == s[0, 0]); // False
}
}
如何解释?在 x86 JIT 中运行时,它会出现在 Visual Studio 2015 的调试版本中。在 x64 JIT 中运行的发布版本按预期打印 True。
从命令行重现:
csc Test.cs /platform:x86 /debug
(/debug:pdbonly、/debug:portable 和 /debug:full 也重现。)
【问题讨论】:
-
ideone.com/li3EzY 是真的。添加更多关于 .net 版本、IDE、编译器的信息
-
这里也一样。但是在摆弄项目设置之后,我发现取消选中“构建”选项卡中的“首选 32 位”复选框使其按预期工作 - 返回 true。所以,对我来说,这看起来像是一个 WoW64 问题。
-
您似乎指出了框架中的错误。
-
有趣的是,通过
ildasm运行损坏的代码,然后通过ilasm“修复”它... -
/debug=IMPL标志使其损坏;/debug=OPT“修复”它。
标签: c# multidimensional-array enumeration