Errors, bugs, questions - page 1637

 
Slawa:

1. Five or four? I'm going to guess a four. Just enlarge the tester window.

2. Take it and test it

Haha, thank you very much (mt4)
1366 x 768 (( a third of the screen needs to be stretched out.
Your clairvoyance skill is on the level.

 
A100:

Let's take an easier example

To put it formally, how many calls of the A( A& ) kind are there? One. At least C++ does not create any intermediate objects

Perhaps RVO (return value optimization) is set by default in C++?
 
A100:

1. Double call of the copy constructor

2. No "leaked memory" message (new without delete)

  1. Correctly told about the RVO optimization (there is also NRVO), it is currently missing in the MQL compiler, but will be added in the future (for now we consider this optimization as a non-priority task).
  2. does not reproduce, please double-check, you may not have specified important details for reproduction.
 
Ilyas: 2. does not reproduce, please double-check, you may not have specified important details for reproduction.

Simplified example

class A { public:
    A()          { Print( __FUNCTION__ ); }
    virtual ~A() { Print( __FUNCTION__ ); }
};
void OnStart()
{
    new A();
}

Result:

2016.08.15 14:17:39.093 Script1 (GBPUSD,M15) A::A

Conclusion: no destructor is called and no memory leak message at the same time (as in the following example)

//Script2.mq5
class A { public:
    A()          { Print( __FUNCTION__ ); }
    virtual ~A() { Print( __FUNCTION__ ); }
};
void OnStart()
{
    A *a = new A();
}

Result:

2016.08.15 14:26:27.993 Script2 (GBPUSD,M15) 16 bytes of leaked memory
2016.08.15 14:26:27.993 Script2 (GBPUSD,M15) 1 object of type A left
2016.08.15 14:26:27.993 Script2 (GBPUSD,M15) 1 undeleted objects left
2016.08.15 14:26:27.992 Script2 (GBPUSD,M15) A::A

 
Thanks for the clarification. Reproduced - no leakage message and here's why:

The optimizer is over-optimized here, since there are no operations on the memory or pointer that were created in the new operator, the allocation of this memory was removed.

We will consider whether to fix this "bug" in the optimizer or to improve it so that saving a pointer into an unused variable won't block deletion of the new operation.

 
Good afternoon.
Please advise the developers why MQL4 and MQL5 have the function of removing an indicator subwindow from an Expert Advisor, while they don't have the function of creating an indicator window.
I have to use templates or start the window indicator manually, which is not convenient because the information on the chart gets lost.
I would also like to be able to start and display indicators from a resource file.
Or advise how to do it.
 
Slawa:

Weren't you the one who organised the "visualisation tip-off"?

What makes you think it is a bug? The name of the folder corresponds to the port number on which the connection was made

It was me..... Thanks, got it.
 
Doing a macro
#define  MACROS(A) "##A##"
I want MACROS(Num) to be replaced by "Num", but the result is always "##A###". Is it possible to define a macro to get what I want?

 

I have made a small discovery for myself

void OnStart()
{  
  double dPrice = 1.08249;
  int iPrice = (int)((dPrice / _Point) + 0.1);
  double dNewPrice = iPrice * _Point; // При этом нормализации это значение не требует в OrderSend
  
  if (dPrice != dNewPrice)
    Print((string)(dPrice - dNewPrice)); 
}

If you open an order at Integer * Point (without normalization) and then request the opening price, it will be different from the non-normalized Integer * Point.

Why does OrderSEnd ALWAYS use non-normalized Integer * Point prices?

 
fxsaber:
I'm doing a macro I want MACROS(Num) to be replaced by "Num", but it always turns out "##A###". Is it possible to define a macro to get what I want?

Remove the inverted commas from the body of the macro

To convert a macro parameter to a string, use #:

#define  MACROS(A) #A
## is used to concatenate tokens
Reason: