[fpc-pascal] 2D Dynamic arrays and BlockRead

andrew.bennett at ns.sympatico.ca andrew.bennett at ns.sympatico.ca
Mon Dec 6 00:35:41 CET 2010

J?rgen Hestermann <juergen.hestermann at gmx.de> wrote

>andrew.bennett at ns.sympatico.ca schrieb: 
>> After using BlockRead to fill a 2D dynamic array, I get an access
>>violation on the very first reference. A 2D array with only one 
>>dimension dynamic works OK. What am I missing? 
>Maybe you blundered into the same trap as so many others who do not know 
>that dynamic arrays are *pointers* (to arrays). It is one of the sins 
>done by Borland to abandon the once strict logic that in Pascal the 
>syntax is always context independend. Now this is no longer the case 
>(i.e. for dynamic arrays). 
After wasting another 2 days reading the documentation, I returned to
blind experiment ... 

I find that BlockRead(F, A[J,0], RightDim*Sizeof(Single), count) works where
BlockRead(F, A[J], RightDim*Sizeof(Single), count) does not.
That is, reading RightDim elements into a space the size of one element
is OK but reading them into a space of the correct size is not.

Personally, I would call that a BUG.

Andrew Bennett


More information about the fpc-pascal mailing list