Download MetaTrader 5

Bug - Try to use class object with no constructor = unhandled exception xc0000005

To add comments, please log in or register
Al W
173
Al W  

This was a pain to find. Definitely a new bug.


First, try this script as is. Then comment out: "Print(sad.Test())" ,and the exception disappears.

Note the class that has no constructor, but has an array doesn't cause an error. Just the ones without constructor or an array causes it...


class HasConstructor
{
   public:
   HasConstructor()
   {
  
   }
   int Test()
   {
      return(1);
   }
  
};

//this one causes exception when Test is called
class HasNoConstructor
{
  
   public:

int testmember;

   int Test()
   {
      return(1);
   }
};


class HasArrayNoConstructor
{
  
   public:

   int testmember[];
  
   int Test()
   {
      return(1);
   }
};

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   HasConstructor happy;
   HasArrayNoConstructor happy2;
   HasNoConstructor sad;

   Print(happy.Test());
   Print(happy2.Test());
  
//comment this out and no more unhandled exception.

   Print(sad.Test());
  }
//+------------------------------------------------------------------+
Ilyas
1213
Ilyas  
circlesquares :

This was a pain to find. Definitely a new bug.

First, try this script as is. Then comment out: "Print(sad.Test())" ,and the exception disappears.

Note the class that has no constructor, but has an array doesn't cause an error. Just the ones without constructor or an array causes it...

Thank you for your message. Bug fixed. Please, wait for updates.
To add comments, please log in or register