Skipped constructor with ArrayResize() - Bug?

Doerk Hilger  

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);
  }
fxsaber  
Doerk Hilger:

this is a bug, right?

Right.

Timo Kosiol  

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.

Ilyas  

Thank you.

Fixed, please wait for the next build

Doerk Hilger  
Ilyas #:

Thank you.

Fixed, please wait for the next build

Thx :) 

fxsaber  
b3037 - OK.
Reason: