[fpc-pascal] Subscript pointers
Michael Van Canneyt
michael at freepascal.org
Thu Jun 22 15:41:03 CEST 2023
On Thu, 22 Jun 2023, Hairy Pixels via fpc-pascal wrote:
> I've forgotten entirely, what does subscripting a pointer do in Pascal? p returns 100 but after that garbage. Seems like a c-style array which doesn't feel right in the language.
> i: Integer;
> p: PInteger;
> p := @i;
> p^ := 100;
It's for easier pointer math, a construct which has been used in FPC since day 1 (AFAIK).
Use with care, since no boundary checks are done.
More information about the fpc-pascal