Errors, bugs, questions - page 2720

 
Once again there is a problem with useless warnings when compiling MT5 code(build 2380).
Please consider disabling unnecessary compiler warnings for the developer:
declaration of 'm_range' hides member   
   in template 'NodeArray<NodeArray<TailArray<int>>>' specified with [T=NodeArray<TailArray<int>>]      
   see previous declaration of 'm_range'        
declaration of 'm_range' hides member
   in template 'NodeArray<NodeArray<NodeArray<TailArray<int>>>>' specified with [T=NodeArray<NodeArray<TailArray<int>>>]
   see previous declaration of 'm_range'

Source Code, Multidimensional Array Prototype (C++ online:https://onlinegdb.com/Hk7QjyRdL):
#define  PRINT(x) ; Print(#x, ":", string(x))

template<typename T>
class TailArray{
protected:
   int m_index;
   T data[];
   
protected:
   TailArray(){}   
public:     
   TailArray(int size){
      ArrayResize(data, size);
      m_index = 0;
   };
   
   T value(){
      int index = m_index;
      m_index = 0;
      return data[index];
   }
   const T operator=(const T value){
      data[m_index] = (T)value;
      m_index = 0;
      return value;
   };
};

template<typename T>
class NodeArray : public T{
protected:
   int m_range;
   
protected:
   NodeArray(){}   
public:     
   NodeArray(const NodeArray &src){ this = src;}
   template<typename T_int> NodeArray(T_int count, T_int r1) : T(count * r1), m_range(r1){}
   template<typename T_int> NodeArray(T_int count, T_int r1, T_int r2) : T(count * r1, r2), m_range(r1){}
   template<typename T_int> NodeArray(T_int count, T_int r1, T_int r2, T_int r3) : T(count * r1, r2, r3), m_range(r1){}
   
   T* operator[](int index){
      this.m_index = this.m_index * this.m_range + index;
      return &this;
   }
};


#define  MultiArray(type, size) MultiArray##size(type)
#define  MultiArray2(type) NodeArray<NodeArray<TailArray<type>>>
#define  MultiArray3(type) NodeArray<NodeArray<NodeArray<TailArray<type>>>>


template<typename T>
class MultiArrayCreate{
public:
   static MultiArray(T, 2) Size(int range_1, int range_2){
      return (MultiArray(T, 2)(range_1, range_2, 1));
   }
   static MultiArray(T, 3) Size(int range_1, int range_2, int range_3){  
      return (MultiArray(T, 3)(range_1, range_2, range_3, 1));
   }
};


void OnStart(){
   MultiArray(int, 2) arr_2 = MultiArrayCreate<int>::Size(4, 4);
   MultiArray(int, 3) arr_3 = MultiArrayCreate<int>::Size(4, 4, 4);
   
   arr_2[0][0] = 2233;
   arr_3[3][3][3] = 4455;
   PRINT(arr_2[0][0].value());
   PRINT(arr_3[3][3][3].value());
}
 

Good afternoon all!

Can you please tell me how to insert a picture in the description of the script in the design and subsequent publication in CodeBase?

I have only, for some reason, insert video from Youtube..., but no icon to insert a picture! :(

Thanks in advance! :)

 
gsl17:

Good afternoon all!

Can you please tell me how to insert a picture in the description of the script in the design and subsequent publication in CodeBase?

I have only, for some reason, insert video from Youtube..., but no icon to insert a picture! :(

Thanks in advance! :)

The insert picture buttonButton illustration is available to the user starting with some minimum rating. You obviously don't have enough rating to work with theButton illustration button.

 
Vladimir Karputov:

The insert picture button is available to the user starting with a certain minimum rating. You obviously do not have a sufficient rating to use the button.

Thanks for the clarification.

That's too bad...

P.S. Yes indeed, this is the first time I've put up a script on CodeBase.

 
Bild 2390 mt 5 profiler on history works on real data no.
 

Defects in template function/class cache operation:
(fixed by MT5(build 2390)) ***(up) Undefined Behavior, you create a complex wrapped object with internal type "C" several times and it turns out to be a completely different data type, maybe "B", maybe "int", whatever you want...
(fixed by MT5(build 2390)) * Compile Error, bug on passing a function pointer as a const ref template argument.
(fixed by MT5(build 2390)) * Compile Error, B<int> object may be created after the B<void*> class object, but a compile error occurs if it is done before.


Defects in template function/class work:
(fixed by MT5(build 2390)) **(up) Compile Error, bug on attempting to access internal class for template parameter of template function.
(fixed by MT5(build 2390)) **(up) Compile Error, bug in template function, passed pointer withinexplicit type conversion behaves like a class otherwise like a pointer.
(not fixed by MT5(build 2390)) *** Compile Error, the main claim to the inappropriate output warning is "deprecated behavior, hidden method calling will be disabled in a future MQL compiler version". The current implementation is firing a cannon at a sparrow.
(not fixed by MT5(build 2390)) ** Compile Error, the bug concerns the return value of a template function when the return value is an internal class inside a template class whose parameter type is set by the argument type of the template function.
(not fixed by MT5(build 2390)) ** Compile Error, namespace and scope bug in template constructor when calling base class when same class name is used in inheritance and internal class.
(not fixed by MT5(build 2390)) * Compile Error, bug on template function call with explicit argument types when called from overloaded non-template function.
(not fixed by MT5(build 2390)) Compile Error, bug on internal class definition - no reference to global namespace when defining a base class.
(fixed by MT5(build 2390)) ** Compile Error, bug with template class code generation when using internal class.
(fixed by MT5(build 2390)) ** Compile Error, bug on template method/class generation, the process of template parameter's auto substitution goes out of scop into the main program code.
(fixed by MT5(build 2390)) * Compile Error, bug with absence of template class code generation when template class acts as return value for template method.
(fixed by MT5(build 2390)) * Compile Error, bug, when internal struct is passed to template function, the receiveddata type cannot be used as a base data type for another internal struct in the template class.
(fixed by MT5(build 2390)) * Compile Error, the check for reused template type names is not performed when declaring a template function inside a template class, which leads to unexpected behavior.
(fixed by MT5(build 2390)) Compile Error, multiple defects related to return "in place created" object when template class/structure is the object.
(fixed by MT5(build 2368)) *( It's not a bug, it's a feature) in base class constructor it is impossible to perform explicit typecast on casting pointer to object of base class to pointer to parent class.
(not fixed by MT5(build 2390)) (new) Compile Error when using default access modifier for inheritance in template class when template parameter acts as base class.
(not fixed by MT5(build 2390)) * (new) Compile Error, when calling an assignment statement via an explicit base class reference. The problem occurs for a template class where the template parameter acts as a base class.


Defects related to call priority mismatch for overloaded functions in MQL vs C++:
(fixed by MT5(build 2390)) **(up) Compile Error when the first of overloaded overloaded template functions uses fully specialized template base class and the second uses unspecialized template base class.
(not fixed by MT5(build 2390)) ** Compile Error, a compile error occurs while generating code for a template function despite the fact that there is an overloaded template function with a suitable signature for the passed parameters.
(not fixed by MT5(build 2390)) * Compile Error, "ambiguous call to overloaded function" when overloaded template functions with different number of template parameters are called.
(fixed by MT5(build 2390)) (corrected by MT5(build 2390)). **(up) Compile Error, call priority of overloaded template functions actually depends on a type of template parameter which theoretically should not affect result of compilation.
(fixed by MT5(build 2390)) *** Compile Error when inheriting classes A <= B <= C <= D and implementing two overloading functions, e.g. one from parameter A* and one from parameter B*, then passing a C* or D* object into such function in MQL causes a compilation error.
(fixed by MT5(build 2390)) (Fixed by MT5(build 2390). ** Runtime, inconsistency in priorities for calls of overloaded template functions.
(Fixed by MT5(build 2390)) *** Runtime, when selecting an appropriate overloaded function for a pointer type argument, the function with type conversion to pointer to parent instead of base class becomes a higher priority.
(not fixed by MT5(build 2390)) *** (new) Compile Error, overloaded template function call priorities.
(not fixed by MT5(build 2390)) ** (new) Compile Error, implicit type conversation is usedwhen calling a function for an argument with data type color despite there being a matching signature overloaded template function with data type color.
(not fixed by MT5(build 2390)) * (new) Compile Error, despite of explicit specialization when overloaded template function is called, template function is called by default anyway, that leads to stack overflow...
(not fixed by MT5(build 2390)) * (new) CompileError, compilation error when a function is called through its pointer, when an array of pointers to a function is used.


Defects related to MetaEditor:
(not fixed by ME5(build 2390)) *** (new) Debugger, crashing of breakpoint instatic structuremethod causes MT terminal to hang.
(not fixed in ME5(build 2390)) ** (new) Compilation, compilation error description can not fit into 256-character limit and is cut off, thus it is impossible to understand which data type error occurs because necessary part has been cut off.
(not fixed in ME5(build 2390)) ** (new) Debugger, StepInto (F11) and set breakpoints do not work.
(not fixed in ME5(build 2390)) ** (new) Debuger, after a breakpoint is triggered instead of continuing code execution by pressing (F5), the same breakpoint is actually triggered again without executing any code.
(not fixed in ME5(build 2390)) *(new) Compilation, incorrect function template parameter signature in Error Description and Parameter info.
(not fixed in ME5(build 2390)) * (new) MetaEditor, the Replace (Strl+H) functionality does not work for the included "In selection" together with "Backward direction", when the necessary part of application is selected, not the whole code.


Defects related to slow function execution, code optimizer works:
(fixed by MT5(build 2390)) **(up) Runtime, large overhead when adding one element at a time into an array using ArrayResize, despite memory being reserved for them, e.g. for structures as much as 7 times slower.


Suggestions:
(new) - add to ME search/replace by current Project, because during refactoring going through each of files and searching for occurrence is somehow not good.
Reference(new) - in ME when compiling to fill the empty columns File, Line, Column with the appropriate information about the source file, from which was made include.
link- about introducing intellisense support for namespace functionality based on intellisense work for static methods in classes.
link- to provide the ability to pass literals and temporary variables as const ref function arguments.
link- whenmoving projectfiles in the Project tab, for moved files that are open and in ME tabs, to automatically update their location path.
link- to introduce typedef declaration functionality in MQL.
link- about providing possibility to force generation of default copy constructors and assignment operators.

 
It's a pity ME doesn't show the paths of the pluggable mqh when compiling, only the names.
 
When showing trading history in "Orders and Deals" mode it is impossible to sort by columns. Because of this, some trades that have just taken place do not go to the end of the list, but to the middle.
 
fxsaber:

A simple example. You need to have an array of MAUs with specified periods.

Each MAP is an object of the same type. It's clear that the MASK is unambiguously specified by the period. Therefore, it is logical to make it const.


Other languages simply make an array of pointers. In MQL, we don't have such freedom.

It would be illogical. If you're not going to change it, it doesn't mean you have to make it const. It is enough to make the variable private.

It would be logical if you got something out of it, but you've only created a problem for yourself.
Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2020.04.21
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
 
Sergey Dzyublik:

Do you know how the MQL optimizer and compiler are designed?
How can you be so sure that const fields of simple types are not used for this purpose?

The optimiser has nothing to do with it.