Invalid use of unpack (1)

Official Description

6.6.5.4 For unpack, it is an error if the parameter of ordinal-type is not assignment compatible with the index-type of the unpacked array parameter.

Simplified Description

In other words, the parameter used to specify the first element of the unpacked array to receive elements transferred from the packed array must be assignment compatible with the index type of the unpacked array. Or to put it another way the first element of the unpacked array to receive elements transferred from the packed array must exist. For example given:

var
   unpacked_value : array[1..10] of integer;
   packed_value : packed array[21..30] of integer;

then

   unpack(packed_value, unpacked_value, 0);

is an error since 0 is not assignment compatible with 1..10. Or to put it another way element 0 of the unpacked array does not exist.

Error Handling

This error is always reported.