Invalid use of pack (3)

Official Description

6.6.5.4 For pack, it is an error if the index-type of the unpacked array is exceeded.

Simplified Description

In other words, it is an error if the pack procedure attempts to transfer array elements from the unpacked array that do not exist. For example given:

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

then

   pack(unpacked_value, 2, packed_value);

means that the pack procedure should attempt to transfer ten elements from the unpacked array (since the packed array has ten elements), starting with the element two. So the pack procedure should transfer elements 2-11 from the unpacked array, but the unpacked array does not have an element 11.

Error Handling

This error is always reported.