Преглед изворни кода

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