[fpc-devel] blockwrite
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Mar 15 22:03:44 CET 2006
On 15 Mar 2006, at 21:40, ϸòð Êîñàðåâñêèé ñ mail.ru wrote:
> I have posted something as bug report #4905, but didn't understand the
> answer (why it is not a bug). Could anyone be specific and correct
> source
> code supplied (it is especially crafted little program of 25 lines
> including program..., end., and empty lines). (Please, look at that
> source before answering, because it seems to me, that fixer didn't.)
Your variable "a:^pbyte;" is not an array, it's a pointer. In Pascal,
arrays and pointers are not the same thing, unlike in C. The fact
that FPC allows you to abuse array notation to "index" pointers
(based on the fact that TP introduced this for pchars) does not
change this.
So if you write blockwrite(a,..), you are passing the address of "a"
to blockwrite, not the address whatever a points to. And because "b"
comes right after "a" in memory, you are first seeing garbage (namely
the pointer value of a) followed by the contents of "b".
Jonas
More information about the fpc-devel
mailing list