[Gambas-user] Array Resize limits

Benoît Minisini gambas at ...1...
Fri Aug 21 02:01:39 CEST 2015


Le 21/08/2015 00:58, martin p cristia a écrit :
> 'thi is the actual (just what's important) code
>
> Public MatRigEst As New Float[]
>
> Function calcular() As Integer
>
>
>       Dim longo As Long, longo2 As Long
>
>       ' longo =  18000 * 6 * 64000  ' = -1677934592 !!!
>
>       'correct value
>       longo = CLong(18000) * 6 * 64000  ' = 6912000000
>
>       MatRigEst.Resize(longo)  '--> no error
>       Debug MatRigEst.Max  ' ----> -1677934592 !!!
>
>
>       'test
>       For longo2 = 0 To longo
>
>           MatRigEst[longo2] = 1000  '--->  Out of bounds on first element
>
>       Next
>
>
> End Function
>

The Resize argument is a 32 bits integer, so the 64 bits integer is 
truncated, and may lead to a negative 32 bits integer. Alas, there is a 
bug where Resize does not raise an error if its argument is negative.

I will fix that in the next revision.

Regards,

-- 
Benoît Minisini




More information about the User mailing list