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

Wrong decompile for 'is' operator in conditional statements.

1 Answer 14 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 01 Apr 2012, 10:51 AM
Hi,

I have noticed a bug when decompiling code which used the 'is' operator in a conditional statement.

Here is a simple reproduction of the issue using an 'if' statement.

Given the following piece of code
object obj = 100;
 
bool test = obj is int;
 
if (obj is int)
{
   ...
}

Here are two tests for checking the type of the boxed value in 'obj'

bool test = obj is int;

decompiles correctly, however when using the same expression as part of a conditional statement as as follows,

if (obj is int)
{
  ...
}

This decompiles to the following

Debug Build
bool flag = obj as int <= null;
if (!flag)
{
  ...
}

Release Build
if (obj as int != 0)
{
  ...
}
As you can see that when the 'is' operator is used in an expression of a conditional statement JustDecompile is decompiling to use the 'as' operator which is not valid when the type we are testing against is a value type.

JustDecompile Version : 2012.1.214.2

Best Regards,

Chris

As you can see that when the 'is' operator is used in an expression of a conditional statement JustDecompile is decompiling to use the 'as' operator which is not valid when the type we are testing against is a value type.JustDecompile Version : 2012.1.214.2Best Regards,Chris

1 Answer, 1 is accepted

Sort by
0
Nikolay G Rusev
Telerik team
answered on 05 Apr 2012, 09:48 AM
Hi Chris,

 Thank you for the feedback. We know about this issue and we have it logged, so it will definitely be fixed in some of the forthcoming releases.
Meanwhile, don't hesitate to write us about any other problems you encounter with JustDecompile.

Kind regards,
Nikolay G Rusev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Nikolay G Rusev
Telerik team
Share this question
or