Skip to content

Commit

Permalink
Fix missing cast in signed uint<int comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Oct 2, 2017
1 parent 8533eda commit 30aa3bd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,15 @@ TranslatedExpression TranslateComp(Comp inst)
// attempt comparison without any additional casts
var rr = resolver.ResolveBinaryOperator(inst.Kind.ToBinaryOperatorType(), left.ResolveResult, right.ResolveResult)
as OperatorResolveResult;
if (rr != null && !rr.IsError
&& NullableType.GetUnderlyingType(rr.Operands[0].Type).GetSign() == inst.Sign
&& NullableType.GetUnderlyingType(rr.Operands[1].Type).GetSign() == inst.Sign)
{
return new BinaryOperatorExpression(left.Expression, op, right.Expression)
.WithILInstruction(inst)
.WithRR(rr);
if (rr != null && !rr.IsError) {
IType compUType = NullableType.GetUnderlyingType(rr.Operands[0].Type);
if (compUType.GetSign() == inst.Sign && compUType.GetStackType() == inst.InputType) {
return new BinaryOperatorExpression(left.Expression, op, right.Expression)
.WithILInstruction(inst)
.WithRR(rr);
}
}

// Ensure the inputs have the correct sign:
KnownTypeCode inputType = KnownTypeCode.None;
switch (inst.InputType) {
Expand Down

0 comments on commit 30aa3bd

Please sign in to comment.