[Lazarus] AV exception error on "lower1 := left" (integer variable assignment)... Can anyone explain this???

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Apr 24 01:31:45 CEST 2011


On Sun, 24 Apr 2011 08:58:07 +1000
Peter E Williams <pewslinuxvault at gmail.com> wrote:

> Hi All,
> 
> I am having a problem with a strange run-time AV error. See the link to the
> Lazarus project.
> 
> Download link:
> http://hotfile.com/dl/115480488/6b7a8ed/dtm_maker_001.zip.html
> 
> The problem is in the QSort procedure:
> 
>[...]
>     pivot := island_single_array[left].location_number;

"pivot" is the key of the pivot element at position "left".

>[...]
>     pivot := island_single_array[left].location_number;
>     left := lower1;
>     right := upper1;
>     if left < pivot then
         ^^^^^^^^^^^^
Comparing a position and a key makes no sense.

You have to keep track of the position of the pivot element. See the
quicksort implementation in TFPList.Sort.

Mattias




More information about the Lazarus mailing list