Can C# 'is' operator suffer under release mode optimization on .NET 4?

前端 未结 4 1122
余生分开走
余生分开走 2021-01-31 15:03

Below is a simple test fixture. It succeeds in Debug builds and fails in Release builds (VS2010, .NET4 solution, x64):

[TestFixture]
public sealed class Test
{
          


        
4条回答
  •  无人共我
    2021-01-31 15:41

    This bug already came up in this SO question by Jacob Stanley. Jacob has already reported the bug, and Microsoft has confirmed that it is indeed a bug in the CLR JIT. Microsoft had this to say:

    This bug will be fixed in a future version of the runtime. I'm afraid it's too early to tell if that will be in a service pack or the next major release.

    Thank you again for reporting the issue.

    You should be able to work around the bug by adding the following attribute to TestChecker():

    [MethodImpl(MethodImplOptions.NoInlining)]
    

提交回复
热议问题