Wrong decompilation

2 posts, 0 answers
  1. annonymous
    annonymous avatar
    1 posts
    Member since:
    Aug 2011

    Posted 24 Aug 2011 Link to this post

    A pair of box !T/unbox.any Int32  is decompiled into (int)variable.
    That obviously will not compile again, it would produce the compiler error "Cannot convert type 'T' to 'int'". It should be (int)(object)variable.
    Similarly box Int32/unbox.any !T is decompiled into (T)something, and that won't compile either and should be (T)(object)something.

    Worse than both of those, code like this: (you guys should add the MSIL language to the format code block, btw)
    box !T
    unbox.any [mscorlib]System.Int32
    box !T
    unbox.any [mscorlib]System.Int32
    box [mscorlib]System.Int32
    unbox.any !T
    Is decompiled into (T)(int)a + (int)b   which as you can see doesn't even get operator precedence right. At the very least it should be (T)((int)a + (int)b)  (that's what ILspy makes of it - and it's also wrong) but it should actually be (T)(object)((int)(object)a + (int)(object)b)  otherwise it will not compile.
  2. Tsviatko Yovtchev
    Tsviatko Yovtchev avatar
    390 posts

    Posted 30 Aug 2011 Link to this post

    Hi there,

     Thanks a bunch for letting us know about these.  Such a feedback is of great value to us since testing all the corner cases on our own is virtually impossible. It would have taken too long for us to find this problem.

    Now that we know about this we'll definitely fix it. Please, stay tuned.

    Kind regards,
    Tsviatko Yovtchev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft R3 2016 release webinar banner
Back to Top