Errors, bugs, questions - page 2679

 
fxsaber:

2365 - the code was sprinkled with errors. Had no time to figure it out yet. I rolled back to 2361 - it was ok. In mq4 - same situation.

Thanks for the message, I will check

 
Downloaded a new version of MT5 (build 2365), unfortunately something is broken,
Seems to be in the parameter passing when calling the constructor of the base class.
 
Sergey Dzyublik:
Bug MT5 (build 2365) Compilation error on implicit constructor call to class using assignment operator, when pointer passing by reference is used as constructor argument.
If pointer passing by reference is replaced by value passing, everything works.

Thanks for the post, fixed

 

MT5 bug (build 2365) compilation error when calling base class constructor when template parameter of template class is used as base class.
No problems in MT5 (build 2363).

class B;

template<typename T>
class A : public T{
public:
   A() : T(){}   // 'B' - identifier expected
};


class B{};

void OnStart(){
   A<B> a;
};
 
Ilyas:
We can see that ArrayResize for objects is faster now.
Once again, the complexity of one part of the ArrayResize function was reduced from logarithm to zero

Thank you very much for speeding up ArrayResize for reserved memory.
MT5 (build 2365) on a real project std::vector::push_back is 1.5 times faster than previous build.
And std::vector:resize lag has decreased from 2.2 times to 1.45 times.

 

build 2366, I think the constants are not working correctly now

class A
{
private:
   int               f1(){Print(__FUNCTION__); return(1);}
   int               f2(){Print(__FUNCTION__); return(2);}
public:
   int               func(int v){const int a = f1(); const int b = f2(); return(a+b+v);}
};

A a1,a2;
//+------------------------------------------------------------------+
void OnStart()
{
   Print("1. ",a1.func(1));
   Print("2. ",a1.func(2));
   Print("3. ",a2.func(3));
   Print("4. ",a2.func(4));
}
//+------------------------------------------------------------------+

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 1. 4

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 2. 5

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 3. 6

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 4. 7

if you replace const with static , it will work as expected - one call to f1() and f2() during initialization of a and b

  int               func(int v){static int a = f1(); static int b = f2(); return(a+b+v);}

2020.03.21 12:58:03.496 tst (EURUSD,H1) A::f1

2020.03.21 12:58:03.496 tst (EURUSD,H1) A::f2

2020.03.21 12:58:03.496 tst (EURUSD,H1) 1. 4

2020.03.21 12:58:03.496 tst (EURUSD,H1) 2. 5

2020.03.21 12:58:03.496 tst (EURUSD,H1) 3. 6

2020.03.21 12:58:03.496 tst (EURUSD,H1) 4. 7

 

If you write code like this, it's a total bug that can't be caught

class A
{
private:
   int               f1()const {static int v1=1; Print(__FUNCTION__); return(v1++);}
   int               f2()const {static int v2=1; Print(__FUNCTION__); return(v2++);}
public:
   int               func(int v){const int a = f1(); const int b = f2(); return(a+b+v);}
};
 
Igor Makanu:

build 2366, I think the constants are not working correctly now

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 1. 4

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 2. 5

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 3. 6

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f1

2020.03.21 12:55:59.904 tst (EURUSD,H1) A::f2

2020.03.21 12:55:59.904 tst (EURUSD,H1) 4. 7

if you replace const with static , it will work as expected - one call to f1() and f2() during initialization of a and b

2020.03.21 12:58:03.496 tst (EURUSD,H1) A::f1

2020.03.21 12:58:03.496 tst (EURUSD,H1) A::f2

2020.03.21 12:58:03.496 tst (EURUSD,H1) 1. 4

2020.03.21 12:58:03.496 tst (EURUSD,H1) 2. 5

2020.03.21 12:58:03.496 tst (EURUSD,H1) 3. 6

2020.03.21 12:58:03.496 tst (EURUSD,H1) 4. 7

This is exactly how it should work.

 
Igor Makanu:

If you write code like this, it's a total undetectable bug.

Everything is correct here too.

 
Koldun Zloy:

This is exactly how it should work.

Last year it didn't work that way - I specially tested const modifiers

and it seems that@Ilyas explained how to run an MQL-program, first all const and static are initialized, no matter where they are described, and then the class constructors are called

ok, with this initialization static / const - it can still be properly distributed, but the fact that the const modifier does not guarantee that the compiler will check this is very unexpected - my second example