diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 7685e88933..8f3bd43e69 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -2209,19 +2209,20 @@ implementation to different kinds of refcounting helpers } (resultdef=left.resultdef)) then begin -{$ifndef llvm} - left.resultdef:=resultdef; - if (nf_explicit in flags) and (left.nodetype = addrn) then - include(left.flags, nf_typedaddr); - result:=left; - left:=nil; -{$else llvm} +{$ifdef llvm} { we still may have to insert a type conversion at the llvm level } - if (nf_explicit in flags) and (left.nodetype = addrn) then - include(flags, nf_typedaddr); - result:=nil; + if left.resultdef<>resultdef then + result:=nil + else {$endif llvm} + begin + left.resultdef:=resultdef; + if (nf_explicit in flags) and (left.nodetype = addrn) then + include(left.flags, nf_typedaddr); + result:=left; + left:=nil; + end; exit; end; end;