Known Issues
Known bugs, quirks and other pecularities

Compiler error with local arrays

After eight years of rather careless use of the compiler, the first problems with releasing memory allocated using a local array were reported at the beginning of 2008. At first the problems were not reproducible, but the latest bug report provided a good start in that direction. The example function causing the problem contained local variables of the type integer only. In fact the declaration part of the function looked like this:
 
Function RC4_Crypt(Txt As String, KeyWord As String) As String
  Dim x As Int16, keypos As Int16, t As Long, j As Int16
  Dim KeyWordLen As Long = Len(KeyWord)
  Dim rc4Next_Rand As Int16
  Dim RC4S(255) As Int16
  Dim RC4K(255) As Int16
  Dim RC4I As Int16, RC4J As Int16, RC4T As Int16
  .. start of the code
  .. a string is generated and assigned to Txt
  Return Txt
EndFunction
 

Each time the function was called the memory consumed by the application increased significantly. The user observed the memory increase using the Task Panel, which shows the number of bytes a program is currently consuming. It was obvious that the memory allocated using the array declaration wasn't released. This is strange because it is explicitly stated that local arrays are cleared automatically. However, in this particular case the memory didn't get freed.

Testing other subroutines revealed that the compiler DOES generate code to clear local arrays, except when the routine doesn't contain a local string variable. Would the developer have declared a local string variable and had he put the characters in that string variable he would never have noticed the problem. Now he used the local variable that was passed as an argument. Adding a declaration of some string variable would have caused the compiler to insert clearing code:

  Dim dummy$
 
Another question was what should happen if the arrays were explicitly freed using the Erase command instead of adding a dummy declaration. Like:
 
Erase RC4S()
Erase RC4K()

Watching the memory consumption in the Task Panel, each call to the function consumed an additional 16 or 20 bytes!
After disassembling the RC4_Crypt function I noticed the difference in array clearing. Erase is not the same as an automatic release of a local array. This caused the additional 16 or 20 bytes of memory consumption.
 
To be sure that a local array is cleared upon leaving the subroutine at least one string must be declared explicitly. A subroutine argument of type string is not sufficient.

Val() and ValDbl() limitation

Val (or ValDbl which is identical) is the workhorse for string to the floating-point conversions. When the number of digits after the dot are more than 13 the Val() function returns wrong values.

Note: this bug has been solved in the build 1165 update