METAEDITOR BUG

 

This code crashes metaeditor. I know it's because of recursion, however, it should not crash the entire program. 

#include <arrays/arrayobj.mqh>


typedef bool (*ArrayFilterFunc) (CObject*);

template <typename T>
class objvector : public CArrayObj {
protected:
   static objvector<objvector<T>*> *s_garbage_collector;
public:
   T operator[](const int index)const{return this.At(index);}
   objvector<T>();
   objvector<T>* filter(ArrayFilterFunc fn) {
      objvector<T>* pass = new objvector<T>();
      m_gc.Add(pass);
      pass.FreeMode(false);
      int size = this.Total();
      for (int i=0; i<size; i++) {
         if (fn(this[i])) {
            pass.Add(this[i]);
         }
      }
      return pass;
   }
};
template <typename T>
objvector<objvector<T>*>* objvector::s_garbage_collector = NULL;
template <typename T>
objvector::objvector() {
   if (!CheckPointer(s_garbage_collector))
      s_garbage_collector = new objvector<objvector<T>*>();
}



void OnStart() {
   objvector<CObject*> objs; 
}

 
nicholi shen:

This code crashes metaeditor. I know it's because of recursion, however, it should not crash the entire program. 

Can anyone else try and replicate? 

 

MQ replied in rus part of the forum.
As I understand the reply - you have incorrect code, but they will fix MetaEditor so the MetaEditor will provide the error message instead of crashing (in such the cases).

Forum on trading, automated trading systems and testing trading strategies

Metaeditor error

Ilyas 2019.03.21 07:56

Thank you for message.
You have an incorrect code - infinite recursion on the template.

We will fix, an error will be issued.

Reason: