Probable bug found on array resizing

 

Hello - I have been testing the MT5 platform for a few weeks, it is really very good and solid.

I have a very curious bug that I have discovered. Here is the minimal code to re-create it (as a script).

Basically, there is something awkward that happends when an array is resized in a different function that where the array was declared.

If you run the code below, the call to MathLog will cause an exception.

void funcalloc( double &x[], int n )
{
  ArrayFree(x);
  ArrayResize(x,n);
   
}


void OnStart()
  {

  double a[];
   
  funcalloc( a, 100 );
   
  a[8] = 2.45;
   
  double res = MathLog( a[8] );
   
   
  }
This is surprising because if a non-const reference is passed to a function, I should be allowed to resize the object, at least in C++

Best regards,

Edward

 
This looks like MQL5 code... You should post it on MQL5.com. And don't forget it's still in beta stages, there are likely to be bugs.
Reason: