Invalid use of pack (1)

Official Description

6.6.5.4 For pack, 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 transfer to 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 transfer to 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

   pack(unpacked_value, 0, packed_value);

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.