Recent

Author Topic: Please, don't even think about compiling this program in FPC [git main]!!!  (Read 2549 times)

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
Code: Pascal  [Select][+][-]
  1. program compilersick;
  2. {$mode objfpc}
  3. type
  4.   TBig = class
  5.   class var A: NativeUInt;
  6.   public
  7.     class procedure B; inline;
  8.     class procedure I; inline;
  9.     class procedure G; inline;
  10.     class procedure Z; inline;
  11.     class procedure Y; inline;
  12.   end;
  13.  
  14. class procedure TBig.B; begin A:=A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A;  end;
  15. class procedure TBig.I; begin B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B; end;
  16. class procedure TBig.G; begin I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I; end;
  17. class procedure TBig.Z; begin G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G; end;
  18. class procedure TBig.Y; begin Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z; end;
  19.  
  20. begin
  21.   TBig.B;
  22. end.
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
Also, please don't even think about compiling this code in FPC 3.2.2!!!

Code: Pascal  [Select][+][-]
  1. program compilersick;
  2.  
  3. var A: byte;
  4.  
  5. procedure B; inline; begin A:=A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A*A; end;
  6. procedure I; inline; begin B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B;B; end;
  7. procedure G; inline; begin I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I;I; end;
  8. procedure Z; inline; begin G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G;G; end;
  9. procedure Y; inline; begin Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z;Z; end;
  10. procedure X; inline; begin Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y; end;
  11. procedure W; inline; begin X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X; end;
  12. procedure V; inline; begin W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W;W; end;
  13.  
  14. begin
  15.   V;
  16. end.

Under no circumstances, I repeat!!!  :D
I may seem rude - please don't take it personally

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
You know what ?  I don't think I have even dreamed of compiling that program. Not once. And having looked at the code, I don't think I will bother to do so now.

Davo

Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

WooBean

  • Sr. Member
  • ****
  • Posts: 303
Also, please don't even think about compiling this code in FPC 3.2.2!!!
...
Under no circumstances, I repeat!!!  :D

Of course I have tried (but this offered for 3.3.1), no problems.
The 3.2.2 version really sinks FPC 3.2.2.

What is going on at Alligator's pond?
« Last Edit: August 06, 2025, 07:53:21 am by WooBean »
Platforms: Win7/64, Linux Mint 22.1 Xia

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
I don't think I have even dreamed of compiling that program. Not once. And having looked at the code, I don't think I will bother to do so now.
Even though you're not going to do it, I still have to warn you: don't do it! Never!  :)
I may seem rude - please don't take it personally

Khrys

  • Sr. Member
  • ****
  • Posts: 456
Also, please don't even think about compiling this code in FPC 3.2.2!!!

Quote from: fpc.exe
[...]
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
sick.pas(15,55) Note: Call to subroutine "procedure X;" marked as inline is not inlined
Linking compilersick.exe
16 lines compiled, 19.8 sec, 368688 bytes code, 1508 bytes data
323200 note(s) issued

Why does the compiler refuse to inline  B  almost one hundred and sixty-four billion times? This is unacceptable  :D

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
What is going on at Alligator's pond?

Okay, let me clarify the conditions for my pond.
Use FPC 3.2.2 via Lazarus (yes, this is more on the Lazarus side in this case).
Well, with 3.2.2, everything works better overall—it's better to test with the [git main] version, of course.

By the way, don't do this under any circumstances!!!
« Last Edit: August 06, 2025, 08:32:16 am by ALLIGATOR »
I may seem rude - please don't take it personally

WooBean

  • Sr. Member
  • ****
  • Posts: 303
Some explanation.

I have tried the first example code (prepared for FPC trunk) but in FPC 3.2.2.

No problem. (The code logic left apart).

Later, after a first morning coffee I noticed that the second example differs from the first and sinks FPC 3.2.2 indeed.

As far as being warned not to do something - any written code (valid or not) can be attempted to compile. Without exclusions!
   
Platforms: Win7/64, Linux Mint 22.1 Xia

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
Code: Pascal  [Select][+][-]
  1. program compilersick2;
  2. {$macro on}
  3. {$define N:=}
  4. {$define X:=N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;}
  5.  
  6. var _: byte;
  7.  
  8. procedure A; inline; begin _:=_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_;   end;
  9. procedure B; inline; begin {$define N:=A} X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X; end;
  10. procedure C; inline; begin {$define N:=B} X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X; end;
  11.  
  12. begin
  13.   C;
  14. end.
I may seem rude - please don't take it personally

Bart

  • Hero Member
  • *****
  • Posts: 5730
    • Bart en Mariska's Webstek
Maybe the same as issue 39622?
I got 1024 time the same hint for a 6 line program...

Bart

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
Maybe the same as issue 39622?

In fact, in this case (my examples), I don't consider this to be a bug, because here I clearly specify multiple function inline calls.

FPC [git main] x64 eats up all my RAM (as a result, it crashes or gives an error; I tested it yesterday, but I can't remember, and I don't want to repeat it—everything started to slow down a lot, and some programs crashed due to lack of memory).

These examples also affect Delphi12.1CE, but there the compiler is 32-bit and eats up 4 gigabytes of memory - it just crashes with an error about insufficient memory.

In FPC [git main] & 3.2.2, another interesting error occurs in the last example - the compiler reports a lack of registers. Which is very strange to me... I can't explain it, what registers are missing and why? Maybe someone knows? Perhaps I would consider this error a candidate for an issue.
« Last Edit: August 07, 2025, 05:08:34 am by ALLIGATOR »
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
I also realized that Lazarus does not read data from the FPC process pipe very efficiently, at least under Windows (by the way, I haven't tested this code on Linux, maybe pipe handling is better there).

Not long ago, I also worked with a console utility from Lazarus via TProcess — I was making (and am still trying to make) a GUI for a console program, and I also encountered the problem of how to read data from Pipe as quickly as possible (because the console process very quickly generates a lot of JSON data in standard output). After a lot of experimentation, I think I found a way to do it quickly (though I've only tested it on Windows so far). When I test everything on Linux, I might look at the work in Lazarus and maybe I'll be able to make some improvements there.
I may seem rude - please don't take it personally

gues1

  • Guest
I also realized that Lazarus does not read data from the FPC process pipe very efficiently, at least under Windows (by the way, I haven't tested this code on Linux, maybe pipe handling is better there).

Not long ago, I also worked with a console utility from Lazarus via TProcess — I was making (and am still trying to make) a GUI for a console program, and I also encountered the problem of how to read data from Pipe as quickly as possible (because the console process very quickly generates a lot of JSON data in standard output). After a lot of experimentation, I think I found a way to do it quickly (though I've only tested it on Windows so far). When I test everything on Linux, I might look at the work in Lazarus and maybe I'll be able to make some improvements there.
What do you mean by "GUI for a console program"? Sounds interesting...

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 440
  • I use FPC [main] 💪🐯💪
What do you mean by "GUI for a console program"? Sounds interesting...

GUI for RipGrep
For searching source code
I may seem rude - please don't take it personally

varianus

  • New Member
  • *
  • Posts: 27
I started a similar project a few years ago. It works quite well, but never had the time to finish it...

https://github.com/varianus/ovosearch

 

TinyPortal © 2005-2018