Errors, bugs, questions - page 3106

 

Contradiction:

struct X {
    X() : i( 1 ) {}
    const int i;
};
void OnStart()
{
    X x1[1] = {};    //(1) нормально ???
    X x2[1];
    ZeroMemory( x2 );//(2) Error: 'x2' - not allowed for objects with protected members or inheritance
}

What is the fundamental difference between (1) and (2) ?

 
A100 #:

Contradiction:

What is the fundamental difference between (1) and (2) ?

1 is initialisation at declaration, 2 is (generally speaking) change.

 
JRandomTrader #:

1 is initialization at declaration, 2 is (in general case) modification.

If x1[0].i can be zero, why can't x2[0].i? How is it worse?

Here is a simplified example of contradiction:

void OnStart()
{
    X x1[1] = {};    //(1) нормально ???
    X x3 = { 0 };    //(3) Error: 'x3' - cannot be initialized with initializer list
}
 
A100 #:

Here is a simplified example of a contradiction:

And here's another one:

void OnStart()
{
    X x1[1] = {};    //(1) нормально ???
    X x2[1];
    Print( x1[0].i == x2[0].i );
}

Result: false

Whereas:

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

A100, 2021.11.16 13:40

struct X {
    X() : i( 1 ) {}
    const int i;
};
 
Error: the software incomprehensibly calculated a transaction made in Roubles 365₽->338₽ (40 shares) and instead of -1020₽ it showed a loss of $148.
If anyone knows, please advise what can be done.
Files:
 

Help from the experts :

struct Y
  {
   int               i;
                     Y(const Y & p): i(p.i) {}
  };

void OnStart()
{
  Y y(y);               // UB?
}

Is it UB or what?

 
Internal compiler error
union X {
    struct XX {char i;} s;
    int i;
} x[1] = {};
void OnStart() {}
5th with {}
 
mktr8591 #:

Is it UB or what?

This is a compiler defect - in theory there should be an error at compile time, because in MQL

Forum on trading, automated trading systems and strategy testing

Errors, Bugs, Questions

A100, 2020.09.30 16:54

That contradicts your own concept that a variable is considered declared when the declaration is finalized. Why did you invent it in the first place? If it's so in one case and different in another

If you rewrite OnStart like this:

void OnStart()
{
  Y y = y; //Error: 'y' - undeclared identifier
}
then the compiler reacts according to the theory of
 
A100 #:

This is a compiler flaw - in theory, there should be an error at the compilation stage, because in MQL

if you rewrite OnStart like this:

then the compiler reacts according to the theory

Exactly.

Thank you!

 

Has anyone figured out how to use the standard library to increase the priority of the panel?

I took the code from the example from here.

In the animation you can see that if you create a panel and then a trend line and put it under the button, the clicks on the button catch click events for the line. The button is ignored.

Tried setting the priority for the button this way: m_button3.ZOrder(100) - but it doesn't help.

There is also a CWnd::BringToTop() method, which I have set for the entire panel and separately for the button. But it's not quite clear how it should work, how to call it correctly and set this priority. Unpairing when calling this method shows that m_id is always equal to -1, although it's the object ID, judging by the comment, but m_name seems to show that the object is involved.


If anyone has a solution, please advise where to dig.