Skipped constructor with ArrayResize() - Bug?

 

Hi,

this is a bug, right?

The constructor should always be excecuted, also with ArrayResize. When changing struct to class, it works in both cases, struct works only with first case, not when using ArrayResize()


struct CA
   {
   public: int intvalue;
   public: CA()
      {
      Print("Constructing CA");
      }
   void operator = (CA & source) { intvalue=source.intvalue; }   
   void operator = (int value)  { intvalue=value; }   
   };

struct S
   {
      CA a;
   };   
   
S s[];   


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  //--- This will execute the constructor 
  CA a=21;
  //--- This will skip the constructor
  ArrayResize(s,1);
  s[0].a = 21;
//---
   return(INIT_SUCCEEDED);
  }
 
Doerk Hilger:

this is a bug, right?

Right.

 

And it's even more strange, if you add a string to the struct like

struct S
   {
      CA a;
      string test;
   };   

The constructor will be executed on ArrayResize.

 

Thank you.

Fixed, please wait for the next build

 
Ilyas #:

Thank you.

Fixed, please wait for the next build

Thx :) 

 
b3037 - OK.
Reason: