소스 검색

Fix tailrec opt. error reoprted in #41412

Disable tailrec optimizationi for functions,
if callnode reuult is not used, because otherwise
the value of second call ends up as the return value.

Fixes bug reoprt #41412
Pierre Muller 1 일 전
부모
커밋
989b173b0b
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      compiler/opttail.pas

+ 3 - 2
compiler/opttail.pas

@@ -72,8 +72,9 @@ unit opttail;
             result:=
               (n.nodetype=calln) and
               (tcallnode(n).procdefinition=p) and
-              not(assigned(tcallnode(n).methodpointer)) and
-              not has_copyback_paras(tcallnode(n));
+              (not assigned(tcallnode(n).methodpointer)) and
+              (not has_copyback_paras(tcallnode(n))) and
+              (cnf_return_value_used in tcallnode(n).callnodeflags);
             if result then
               usedcallnode:=tcallnode(n)
             else