How can we help you today? How can we help you today?

.NET Reflector incorrectly disassembles (a ? b : c) << d

There appears to be a bug in .NET Reflector when handling (a ? b : c) << d.

To reproduce it compile the following code using .NET 3.5:
using System;

class P
&#123;
    static void Main&#40;&#41;
    &#123;
        int i = 0;
        bool k = false;
        int j = &#40;k ? 1 : 0&#41; &lt;&lt; i;
        Console.WriteLine&#40;j&#41;;
    &#125;
&#125;

The program should print "0" to the console.

Disassemble the resulting Main() method in the .exe using .NET Reflector 5.1.5.0 and you get this:
private static void Main&#40;&#41;
&#123;
    int i = 0;
    bool k = false;
    int j = &#40;&#40;k != null&#41; ? 1 : 0&#41; &lt;&lt; i;
    Console.WriteLine&#40;j&#41;;
&#125;

This program when compiled outputs "1". The main funtion is disassembled incorrectly.
MarkByers
0

Add comment

Please sign in to leave a comment.