Re: [fpc-pascal] LLVM crash

2023-08-15 Thread Benito van der Zander via fpc-pascal
writing this mail) Then this: https://gitlab.com/freepascal.org/fpc/source/-/issues/40280 is causing a stack corruption https://gitlab.com/freepascal.org/fpc/source/-/issues/40392 is causing a heap corruption Cheers, Benito On 11.08.23 12:57, Jonas Maebe via fpc-pascal wrote: On 10/08/2023

Re: [fpc-pascal] LLVM LTO

2023-08-15 Thread Benito van der Zander via fpc-pascal
, Benito On 11.08.23 12:46, Jonas Maebe via fpc-pascal wrote: On 10/08/2023 17:06, Benito van der Zander via fpc-pascal wrote: I tried to use the LLVM Link-Time-Optimization, -Clflto I should update the wiki page. Under Debian 11, I can tell FPC to use gold with lto by specifying the following

[fpc-pascal] LLVM LTO

2023-08-11 Thread Benito van der Zander via fpc-pascal
Hallo, I tried to use the LLVM Link-Time-Optimization, -Clflto I compiled/installed fpc llvm with a separate prefix, which was already difficult to set up Then the default linker did not want to link it. The wiki says to use the gold linker. I do not know how to change the linker in

[fpc-pascal] LLVM crash

2023-08-10 Thread Benito van der Zander via fpc-pascal
Hallo, i tried to run my program under LLVM (from july fpc)  and it crashes? Program received signal SIGSEGV, Segmentation fault. 0x0042e5f1in SYSTEM_$$_SYSGETMEM_FIXED$QWORD$$POINTER() (gdb) bt #0 0x0042e5f1in SYSTEM_$$_SYSGETMEM_FIXED$QWORD$$POINTER() #1 0x0041b92ain

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Benito van der Zander via fpc-pascal
Hi, That 99.99% of people does use it, indicates they simply take the overhead because of the advantages that the managed types offer. Or they simply do not know about the overhead Like I was writing all my code on Windows 98, and never noticed any overhead, until I started running

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Benito van der Zander via fpc-pascal
. That is a very productive optimization idea Cheers, Benito On 24.05.23 13:10, Marco van de Voort via fpc-pascal wrote: On 24-5-2023 13:00, Benito van der Zander via fpc-pascal wrote: It is weird that your code calls setjmp? Are you using a non Windows platform?  Comparisons with Delphi should be done

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Benito van der Zander via fpc-pascal
Zander via fpc-pascal wrote: Hi, Depends on your code. I wrote all my code in Delphi 4. From 1998 or so. I do not make new projects, only maintain old ones. Delphi 4 felt much better. Like take: procedure test; var s: string; begin   s:= 'abc'; end; It is weird that your code calls

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Benito van der Zander via fpc-pascal
Hi, The compiler will do this wrapping anyway if you use ansistrings, so the approach with e.g. a generic record will not cause a lot of overhead in most cases. But using strings or anything similar causes a lot of overhead It is really bad Bye, Benito On 21.05.23 18:03, Michael Van

[fpc-pascal] pointer to char vs pchar

2023-03-24 Thread Benito van der Zander via fpc-pascal
Hallo, why is a pointer to a char not a pchar (for type helpers)? program Project1; {$Mode objfpc}{$H+} {$ModeSwitch typehelpers} type TPcharHelper = type helper for pchar   function toString(length: integer): string; end; function TPcharHelper.toString(length: integer): string; begin  

Re: [fpc-pascal] Arguments gets corrupted with anonymous nested function

2022-09-07 Thread Benito van der Zander via fpc-pascal
Hi, https://gitlab.com/freepascal.org/fpc/source/-/issues/38703 I'm afraid that with -O4 it is by design. -O4 enables -OoUNCERTAIN, and the documentation about -OoUNCERTAIN notes that: “If uncertain optimizations are enabled, the CSE algorithm assumes that — If something is written to a

Re: [fpc-pascal] Compiler flag define or $IFOPT for optimizations

2022-06-03 Thread Benito van der Zander via fpc-pascal
tch on every commit. Best, Benito On 28.05.22 14:34, Tomas Hajny via fpc-pascal wrote: On 2022-05-28 13:44, Benito van der Zander via fpc-pascal wrote: Hi, I want to show how my program was compiled. Now I have string like "FPC3.2.2 i386-Linux R+C+" from   compiler := 'FPC' + {$INCLUD

Re: [fpc-pascal] Feature Announcement: Function References and Anonymous Functions

2022-05-28 Thread Benito van der Zander via fpc-pascal
Hi, Sort((left, right) begin if left < right then result := -1 else if left > right then result := 1 else result := 0; end); One could

[fpc-pascal] Compiler flag define or $IFOPT for optimizations

2022-05-28 Thread Benito van der Zander via fpc-pascal
Hallo, I want to show how my program was compiled. Now I have string like "FPC3.2.2 i386-Linux R+C+" from   compiler := 'FPC' + {$INCLUDE %FPCVERSION%} + ' ' + {$INCLUDE %FPCTargetCPU%}+'-'+{$INCLUDE %FPCTargetOS%}+ ' ' + {$IfOpt R+}+'R+'{$endif} {$IfOpt S+}+'S+'{$endif} {$IfOpt

Re: [fpc-pascal] StrToInt is using ShortString buffer?

2022-01-14 Thread Benito van der Zander via fpc-pascal
Hi, I don’t see what the problem with a shortstring buffer is.. strtoint could not make use of an input string longer than 256 characters anyway, because the output integer could not have more than 19 digits anyway.. so an input string longer than this would be useless… just convert to a

Re: [fpc-pascal] StrToInt is using ShortString buffer?

2022-01-12 Thread Benito van der Zander via fpc-pascal
Hi, If it is correct: Can we skip using ShortString buffer and have e.g. 'common' PChar base function for AnsiString/ShortString? I keep arguing for that as well You can always create such a function yourself,  gain experience using it, and share the source with us. I wrote that for

Re: [fpc-pascal] Where can I find working code for xidel and dependencies

2022-01-11 Thread Benito van der Zander via fpc-pascal
Hi, xquery.internals.common.pas(434,80) Fatal: Cannot find PasDblStrUtils used by xquery.internals.common of package internettools. that is here: github.com/bero1985/pasdblstrutils Download src/PasDblStrUtils.pas. Do not clone the repository when you have a slow internet connection It

Re: [fpc-pascal] Traits Proposal

2021-02-18 Thread Benito van der Zander via fpc-pascal
Hi, The problem is that, we like OOP inheritance but when we extend classes we are forced into a single hierarchy. there is another way to extend classes without inheritance: type helpers Traits are like reverse type helpers. With the type helper you first declare the class and then the

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
On 17.02.21 21:43, Ryan Joseph via fpc-pascal wrote: So where is your 10% performance hit coming from then? on init: InitInterfacePointers or TInterfacedObject.AfterConstruction? I benchmarked it years ago, I do not remember the details. But InitInterfacePointers was bad. Just look at it:

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
k to the class (sub    $0x20,%rdi) before calling the actual method. Because the class method assumes self is the class and not an interface Bye, Benito On 17.02.21 17:37, Ryan Joseph via fpc-pascal wrote: On Feb 17, 2021, at 8:27 AM, Benito van der Zander via fpc-pascal wrote: var

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
8 With many small objects it should be faster just because it fits better in the cache. Cheers, Benito On 17.02.21 14:31, Marco van de Voort via fpc-pascal wrote: Op 2021-02-17 om 00:02 schreef Benito van der Zander via fpc-pascal: And there often is a lot of unintentional deep copying. This is als

Re: [fpc-pascal] Traits Proposal

2021-02-16 Thread Benito van der Zander via fpc-pascal
Hi, And there often is a lot of unintentional deep copying. This is also why a property returning a record is fairly useless except for extremely small records like TPoint (and even that is not optimal no But a managed record to replace an interface, would only contain a single

Re: [fpc-pascal] Traits Proposal

2021-02-16 Thread Benito van der Zander via fpc-pascal
Hi, If you need to create 1000 class instances each frame then you have a flaw in your logic in my opinion. I have more like a million class instances For my XPath stuff, and every returned value is put in a variant-like class. Selecting all nodes on an GB large XML, could even create

Re: [fpc-pascal] Traits Proposal

2021-02-16 Thread Benito van der Zander via fpc-pascal
There are no significant performance implications of interfaces. They're essentially a virtual method call, something that one is doing all day long with Object Pascal classes. Interfaces are extremely slow. Virtual method calls are also slow. I have been using interfaces for reference

Re: [fpc-pascal] Question about System.Move()

2021-01-29 Thread Benito van der Zander via fpc-pascal
strings before your code and then decrementing the reference counts afterwards would probably work. The same probably applies to other reference count objects. Derek On Thu, Jan 28, 2021 at 11:35 AM Benito van der Zander via fpc-pascal <mailto:fpc-pascal@lists.freepascal.org>> wrote

Re: [fpc-pascal] Question about System.Move()

2021-01-27 Thread Benito van der Zander via fpc-pascal
calls,  which is around a third of 3*n*k Bye, Benito On 11.01.21 18:51, Sven Barth via fpc-pascal wrote: Benito van der Zander via fpc-pascal <mailto:fpc-pascal@lists.freepascal.org>> schrieb am Mo., 11. Jan. 2021, 15:26: Hi, perhaps a  safe, generic function for this copy

Re: [fpc-pascal] Question about System.Move()

2021-01-11 Thread Benito van der Zander via fpc-pascal
Hi, perhaps a  safe, generic function for this copying could be added to the RTL. Like: Procedure ManagedMove(const source: T;var dest: T;count: SizeInt); a) For non-managed types it would be the same as Move(source, dest, count*sizeof(T)) b) For reference counted types (like strings or

[fpc-pascal] CP_NONE string disappearing

2020-12-27 Thread Benito van der Zander via fpc-pascal
Hello, this code: program Project1; {$mode objfpc}{$H+} var a,b, c: string; begin   a := 'x';   b := 'y';   SetCodePage(RawByteString(b), CP_NONE, false);   c := a+b;   writeln(c); end. prints x without y on win32/wine. Is that supposed to happen? Bye, Benito

Re: [fpc-pascal] I'm working on automated Help Output for console apps

2020-11-20 Thread Benito van der Zander via fpc-pascal
Hi, I also made such a thing: var optionsreader: TCommandLineReader; begin   optionsreader := TCommandLineReader.create;   optionsreader.declareFile('file', 'The file to be processed');   optionsreader.addAbbreviation('f');   optionsreader.declareFlag('help', '');  

Re: [fpc-pascal] link.res search dirs when cross compiling [solved]

2020-11-18 Thread Benito van der Zander via fpc-pascal
wrote: Op 2020-11-18 om 19:21 schreef Benito van der Zander via fpc-pascal: where do the SEARCH_DIRs in link.res come from? Some are hardcoded, and fpc.cfg might contain -Fl lines with paths too from parsing ld.so.conf on install ___ fpc-pascal

Re: [fpc-pascal] link.res search dirs when cross compiling

2020-11-18 Thread Benito van der Zander via fpc-pascal
How are you specifying your cross-compilation sysroot? Make sure you use the -XR parameter for that, I use -Fl in ~/.fpc.cfg... When I use -XR nothing happens. The link.res is the same, except -Fl prepends the path to link.res and -XR just ignores it. (same for -Xr) Benito

[fpc-pascal] link.res search dirs when cross compiling

2020-11-18 Thread Benito van der Zander via fpc-pascal
Hi, where do the SEARCH_DIRs in link.res come from? My build has started failing, after trying it on a new computer with "/home/benito/bin/arm-linux-androideabi-ld.bfd:android/libs/armeabi/link42815.res:17: ignoring invalid character `'' in expression" link.res starts with:

Re: [fpc-pascal] Adding file to string to the RTL

2020-10-09 Thread Benito van der Zander via fpc-pascal
They cannot be used on handles that do not support FileSeek() (sockets, pipes, stdin/stdout etc.). Well, it would be better if it could You can just incrementally resize the return array, when reading succeeds after seeking fails. I have a string load function doing that:

[fpc-pascal] json parsing: detecting invalid escape sequences

2020-09-29 Thread Benito van der Zander via fpc-pascal
Hi, I am supposed to find invalid escape sequences when parsing JSON and replace them with a user defined fallback. Invalid in the sense that the unicode codepoint is not defined or a missing surrogate, not syntactically invalid. For example, any occurrence of \u and \uDEAD should be

[fpc-pascal] json numbers with leading dots

2020-09-29 Thread Benito van der Zander via fpc-pascal
Hi, there are also two lines in the json scanner where it tries to repair numbers with leading dots '.123' to '0.123': If (FCurTokenString[1]='.') then   FCurTokenString:='0'+FCurTokenString; They should probably be removed. Not only are those numbers invalid in json, it is

Re: [fpc-pascal] json parser line numbers

2020-09-29 Thread Benito van der Zander via fpc-pascal
here: https://bugs.freepascal.org/view.php?id=37836 On 29.09.20 10:47, Michael Van Canneyt via fpc-pascal wrote: On Tue, 29 Sep 2020, Benito van der Zander via fpc-pascal wrote: Hi, the line numbering of the json parser has been changed recently. It used to say "Error at line 1&quo

[fpc-pascal] json parser line numbers

2020-09-29 Thread Benito van der Zander via fpc-pascal
Hi, the line numbering of the json parser has been changed recently. It used to say "Error at line 1"... when there was an error in the first line, but now it says "Error at line 0"... Was that on purpose, or can someone change it back? Benito

Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-14 Thread Benito van der Zander via fpc-pascal
Hi, I would definitely keep it that way. As I see it: Redirection or not should not matter, the system should assume console output. Things like 'tee' make this concept dubious in any case: If you pipe output to a program, you don't expect the codepage to change because of the

Re: [fpc-pascal] Procedural generics question

2020-08-25 Thread Benito van der Zander via fpc-pascal
Hi, that is generating rather odd code (r40721) project1.lpr:9    begin 00401090 55   push   %rbp 00401091 4889e5   mov    %rsp,%rbp 00401094 488d6424f0   lea -0x10(%rsp),%rsp 00401099