[fpc-pascal] Subscript pointers

Hairy Pixels genericptr at gmail.com
Sun Jun 25 06:20:53 CEST 2023

> On Jun 24, 2023, at 8:00 PM, Steve Litt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> I don't do much with Pascal pointers, but it looks to me like you:
> * Set p to the address of i
> * Set the contents of p to 100
> * Read the contents of p, which of course would be the value of i, 100
> * Read the contents of p+1, which would be one integer width away on
>  the stack, and has not been assigned to anything.

Indeed that's what it's doing. It's strange as an array syntax though which suggests there's a range of uniform elements, when in reality there's just a pointer to a single location. 

I think the more correct Pascal way to do it would be define an array type and pointer to that type and then  subscript that instead of the C-style way.

Ryan Joseph

More information about the fpc-pascal mailing list