This is a migrated thread and some comments may be shown as answers.

Wrong decompilation

1 Answer 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
annonymous
Top achievements
Rank 1
annonymous asked on 24 Aug 2011, 09:02 AM
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)
ldarg.0
box !T
unbox.any [mscorlib]System.Int32
ldarg.1
box !T
unbox.any [mscorlib]System.Int32
add
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.

1 Answer, 1 is accepted

Sort by
0
Tsviatko Yovtchev
Telerik team
answered on 30 Aug 2011, 01:29 PM
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 >>

Tags
General Discussions
Asked by
annonymous
Top achievements
Rank 1
Answers by
Tsviatko Yovtchev
Telerik team
Share this question
or