From cf3c4e40391ace1ae7b188c1f387a3474a96accb Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 3 Sep 2017 13:34:33 +0200 Subject: [PATCH] Add special case for 0u -> null conversion. --- ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs index 892d40414..c289459bb 100644 --- a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs @@ -289,7 +289,12 @@ namespace ICSharpCode.Decompiler.CSharp return expressionBuilder.ConvertConstantValue(rr) .WithILInstruction(this.ILInstructions); } - if (targetType.Kind == TypeKind.Pointer && 0.Equals(ResolveResult.ConstantValue)) { + if (targetType.Kind == TypeKind.Pointer && (0.Equals(ResolveResult.ConstantValue) || 0u.Equals(ResolveResult.ConstantValue))) { + if (allowImplicitConversion) { + return new NullReferenceExpression() + .WithILInstruction(this.ILInstructions) + .WithRR(new ConstantResolveResult(targetType, null)); + } return new CastExpression(expressionBuilder.ConvertType(targetType), new NullReferenceExpression()) .WithILInstruction(this.ILInstructions) .WithRR(new ConstantResolveResult(targetType, null));