Re: [fpc-pascal] Pointer question

2023-08-10 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Do., 10. Aug. 2023, 18:30: > > > > On Aug 10, 2023, at 5:43 AM, Bernd Oppolzer via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > PTRADD (p, i) - p is type ANYPTR, i is integer, result is of type ANYPTR > > PTRDIFF (p1, p2) - two pointers,

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Michael Van Canneyt via fpc-pascal
On Thu, 10 Aug 2023, Hairy Pixels via fpc-pascal wrote: On Aug 10, 2023, at 10:49 AM, Sven Barth via fpc-pascal wrote: Then you simply aren't using them often enough. E.g. the RTTI internal code is full of them and additional typecasts would simply muddle up otherwise relatively

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Hairy Pixels via fpc-pascal
> On Aug 10, 2023, at 10:49 AM, Sven Barth via fpc-pascal > wrote: > > Then you simply aren't using them often enough. E.g. the RTTI internal code > is full of them and additional typecasts would simply muddle up otherwise > relatively clear code. > Here's a question, what is the full

[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] Pointer question

2023-08-10 Thread Hairy Pixels via fpc-pascal
> On Aug 9, 2023, at 4:37 PM, Tomas Hajny via fpc-pascal > wrote: > > No, the offset is not a memory address but just a number of bytes (which is > also the reason why you cannot add the pointers together, but you can add a > number to a pointer. As an example, you could use this operation

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Hairy Pixels via fpc-pascal
> On Aug 10, 2023, at 5:43 AM, Bernd Oppolzer via fpc-pascal > wrote: > > PTRADD (p, i) - p is type ANYPTR, i is integer, result is of type ANYPTR > PTRDIFF (p1, p2) - two pointers, the result is integer > ANYPTR is a predefined type, compatible with every (typed pointer) > ADDR (x) is a

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Michael Van Canneyt via fpc-pascal
On Thu, 10 Aug 2023, Hairy Pixels via fpc-pascal wrote: On Aug 10, 2023, at 4:23 PM, Hairy Pixels wrote: // 4) subscript (inc and dereference in one step) v := i[1]; #4 was not in the list for example so I wonder what others exist. I found another one in the typinfo.pp unit. What

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Hairy Pixels via fpc-pascal
> On Aug 10, 2023, at 4:23 PM, Hairy Pixels wrote: > > // 4) subscript (inc and dereference in one step) > v := i[1]; > > > #4 was not in the list for example so I wonder what others exist. I found another one in the typinfo.pp unit. What does, 1) taking the address of a type

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Hairy Pixels via fpc-pascal
> On Aug 10, 2023, at 2:18 PM, Michael Van Canneyt via fpc-pascal > wrote: > > https://www.freepascal.org/docs-html/current/ref/refse15.html#x42-620003.4 This document doesn't really do a great enumerating all the operators so I'm not sure if the list is complete. I think the list is: var

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Elmar Haneke via fpc-pascal
1) what does "i := x - x;" do and what is it's purpose and why doesn't "x + x" work the same? Subtracting pointers may be useful if they point to consecutive memory. The Result is the number of bytes between both addresses. Adding pointers is useless, you would get a pointer pointing to

Re: [fpc-pascal] Pointer question

2023-08-10 Thread Bernd Oppolzer via fpc-pascal
FWIW, when I added similar functionality to my Stanford Pascal compiler, I chose not to allow arithmetic of pointers, but instead I added some functions: PTRADD (p, i) - p is type ANYPTR, i is integer, result is of type ANYPTR PTRDIFF (p1, p2) - two pointers, the result is integer ANYPTR is a