Recursion broken recently by -OoDeadValues in mainline FPC (3.3.1) lazarus / 21-General ---------------------------------------------------------------------- Bogen85 · 2022-11-08 08:38 I'll likely file an issue on this soon. Recursion with -OoDeadValues was working a week or so ago in mainline git, have not determined when it broke. Given the following program: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program recurse; procedure pr1(const i, final: integer);  var i0: integer;   procedure pr2(const i1: integer);    begin      if i0 > final then exit;      if i1 > final then exit;      writeln(i0, ' ', i1);      inc(i0);      pr2(i1+1);    end;  begin    i0 := i;    pr2(i);  end; begin  pr1(1, 5);end.  Compiled and ran with FPC stable, it runs correctly: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ fpc \      -gl -gw3 -Xi -Sm -Sg -Os -Mobjfpc -Sh \        -MadvancedRecords \        -McVar -MhintDirective \        -OoPeepHole -OoTailRec -OoRemoveEmptyProcs -OoConstProp \        -OoDFA -OoCSE -OoDeadStore -OoDeadValues \        -vnewh -Sewh ./recurse.pas && mv recurse recurse-stable && ./recurse-stableHint: Start of reading config file /etc/fpc.cfgHint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 3.2.2 [2022/08/31] for x86_64Copyright (c) 1993-2021 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling ./recurse.pasLinking recurse21 lines compiled, 0.1 sec2 hint(s) issued1 12 23 34 45 5  Compiled and ran with FPC mainline as follow, it fails: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ fpc -gl -gw3 -Xi -Sm -Sg -Os -Mobjfpc -Sh \        -MfunctionReferences -ManonymousFunctions -MadvancedRecords \        -McVar -MimplicitFunctionSpecialization -MhintDirective \        -OoPeepHole -OoTailRec -OoRemoveEmptyProcs -OoConstProp \        -vnewh -Sewh \      -OoDFA -OoCSE -OoUnusedPara -OoDeadStore \        -OoDeadValues \        ./recurse.pas && mv recurse recurse-current && ./recurse- currentHint: Start of reading config file /home/dev/fpc_usr/lib/fpc/etc/fpc.cfgHint: End of reading config file /home/dev/fpc_usr/lib/fpc/etc/fpc.cfgFree Pascal Compiler version 3.3.1 [2022/11/07] for x86_64Copyright (c) 1993-2022 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling ./recurse.pasLinking recurse21 lines compiled, 0.2 sec, 156832 bytes code, 1139976 bytes data2 hint(s) issued1 12 13 14 15 1  Remove the -OoDeadValues and it succeeds: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $  fpc -gl -gw3 -Xi -Sm -Sg -Os -Mobjfpc -Sh \        -MfunctionReferences -ManonymousFunctions -MadvancedRecords \        -McVar -MimplicitFunctionSpecialization -MhintDirective \        -OoPeepHole -OoTailRec -OoRemoveEmptyProcs -OoConstProp \        -vnewh -Sewh \      -OoDFA -OoCSE -OoUnusedPara  -OoDeadStore \        ./recurse.pas && mv recurse recurse-current && ./recurse-currentHint: Start of reading config file /home/dev/fpc_usr/lib/fpc/etc/fpc.cfgHint: End of reading config file /home/dev/fpc_usr/lib/fpc/etc/fpc.cfgFree Pascal Compiler version 3.3.1 [2022/11/07] for x86_64Copyright (c) 1993-2022 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling ./recurse.pasLinking recurse21 lines compiled, 0.2 sec, 156848 bytes code, 1139976 bytes data2 hint(s) issued1 12 23 34 45 5  Mainline used: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ git describe3.3.1-12089-ga2789d611f ---------------------------------------------------------------------- Bogen85 · 2022-11-08 08:41 I know that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if i1 > final then exit; is redundant. What I consider failing is i1 not incrementing. ---------------------------------------------------------------------- Bogen85 · 2022-11-08 14:58 This highlights the issue more explicitly, both counters should track, and termination should be based on i1, not i0 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program recurse; procedure pr1(const i, final: integer);  var i0: integer;   procedure pr2(const i1: integer);    begin      if i1 > final then exit;      if i0 > (final*2) then exit;      writeln(i0, ' ', i1);    inc(i0);      pr2(i1+1);    end;  begin    i0 := i;    pr2(i);  end; begin  pr1(1, 5);end.  Broken output: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 1 12 13 14 15 16 17 18 19 110 1  Correct output: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 1 12 23 34 45 5 ---------------------------------------------------------------------- Bogen85 · 2022-11-11 08:28 https://gitlab.com/freepascal.org/fpc/source/-/issues/39988