Sorting an array can cause a crash
Jump to navigation
Jump to search
Description
When sorting an array LB MAY stop with an inappropriate and incorrect error message. Runtime error: 6 is out of range for a(
Example code to demonstrate the bug.
N=5
M=6
dim a(N,M)
randomize .5
for i = 1 to N
for j = 1 to M
a(i,j)=int(rnd(1)*10)
next
next
gosub [show]
sort a(), 1, N, 6 'breaks when sorted by column 6 'with Runtime error: 6 is out of range for a(
gosub [show]
end
[show]
for i = 1 to N
for j = 1 to M
print a(i,j); " ";
next
print
next
print
return
Example code to work around the bug.
Seen only in arrays of less than 10 rows?? Bypassed by dimension unnecessarily high for the expected number of rows.