{$OPTIMIZATION REMOVEEMPTYPROCS} and nested procedures lazarus / 62-General ---------------------------------------------------------------------- 440bx · 2020-04-25 20:24 Hello, {$OPTIMIZATION REMOVEEMPTYPROCS}  seems to work as expected when the empty procedure is _not_ nested.  When the procedure is nested, there does not seem to be a way to convince the compiler to remove it. consider the following example: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 {$OPTIMIZATION REMOVEEMPTYPROCS}   // {$DEFINE TRACK_ERROR_LINE} program EmptyProc; procedure OuterProc();  var    NotNeeded1, NotNeeded2 : integer;    p                      : pchar;   procedure TrackErrorLine();  begin    {$IFDEF TRACK_ERROR_LINE} writeln('Error line : ', p); {$ENDIF}  end;    procedure Aprocedure(var x : integer);  var    a, b, c : integer;   begin    { give the compiler something to do }     x := a * b + c;     { do plenty of other stuff  }     {$IFDEF TRACK_ERROR_LINE} p := {$I %LINE%}; {$ENDIF}    TrackErrorLine();  end; begin  Aprocedure(NotNeeded1);end;  begin  OuterProc();    writeln('press enter/return to end this program');  readln;end.Changing the code to remove OuterProc (and include a call to Aprocedure instead of OuterProc) thereby making the TrackErrorLine() procedure not nested will yield the desired and expected results but, not otherwise. Suggestions on how to convince the compiler to remove the empty nested proc are most welcome. Thank you. ---------------------------------------------------------------------- jamie · 2020-04-26 00:56 Well as I hear quite often, "Memory is cheap, why worry" ---------------------------------------------------------------------- winni · 2020-04-26 01:26 Hi! With the memory and the CPU cycles which are today needed to make a moving window semi-transparent they flew 1969 to the moon ..... Winni ---------------------------------------------------------------------- PascalDragon · 2020-04-26 10:33 Quote from: 440bx on April 25, 2020, 10:24:54 pmSuggestions on how to convince the compiler to remove the empty nested proc are most welcome. By reporting a bug. The problem is twofold: - a nested routine is not detected as empty, because it always sets up its frame pointer to the parent's frame - nested routines are processed after the containing routine, so the compiler has not yet run the detection whether the routine is empty ---------------------------------------------------------------------- 440bx · 2020-04-26 11:06 Quote from: PascalDragon on April 26, 2020, 12:33:00 pmBy reporting a bug. Done.  Ticket : 0036977