C# 'is' type check on struct - odd .NET 4.0 x86 optimization behavior

前端 未结 6 929
孤城傲影
孤城傲影 2021-02-02 07:20

Update: I have filed a bug report with Microsoft Connect, please vote for it!

Update 2: Microsoft have marked the bug report as fixed

6条回答
  •  隐瞒了意图╮
    2021-02-02 07:58

    Here's my results on XP SP3 (x86):

    >runtest
    Compiler: Framework\v4.0.30319\csc.exe
    False => x86
    False => x86 (Optimized)
    True => x86 (Debug)
    False => x86 (Debug + Optimized)
    False => AnyCPU
    False => AnyCPU (Optimized)
    True => AnyCPU (Debug)
    False => AnyCPU (Debug + Optimized)
    
    >runtest v3.5
    Compiler: Framework\v3.5\csc.exe
    True => x86
    True => x86 (Optimized)
    True => x86 (Debug)
    True => x86 (Debug + Optimized)
    True => AnyCPU
    True => AnyCPU (Optimized)
    True => AnyCPU (Debug)
    True => AnyCPU (Debug + Optimized)
    

    The interesting point about this result is that the .NET 4 target fails on AnyCPU (running as x86) but works on AnyCPU (running as x64).

提交回复
热议问题