[CLOSED] : Compiler bug with template parameter = void* - page 4

 
Dmitry Fedoseev:

Have you tried reading the link you gave us? Slava there popularly explains why it is so - because the priority was mixed up in the old MQL4. So now it is important to attract attention. It's not even good that there is only a warning, it would be better if there is an error.

Or, a slap in the face

 
Dmitry Fedoseev:

Have you tried reading the link you gave us? Slava there popularly explains why it is so - because the priority was mixed up in the old MQL4. So now it is important to attract attention. It's not even good that there is only a warning, it would be better if there was an error.

So? Here:

int i = 1 << 2 + 3;

Also in MQL4 the priority was mixed up? It's about the general approach, not the special case. In the particular case you can give a warning/error (as an exception) but why should it be extended to everything else?

Besides, in MQL4 (as far as I know) let's say the || operator has no laziness. And despite this, the MQL5 compiler does not generate a warning in similar cases (it does not suggest to break || into several atomic operations)

From which it follows that the corresponding page of history is reversed

 

I would like to add to ... that even the Documentation says:

"To change the order of operations, parentheses are used, which have the highest priority".

which implies that the use of parentheses for other purposes (not related to changing the order) must still be justified

 
fxsaber:

I wonder where the threshold for the number of programmers is when one should hesitate? 5 is not enough. 1,000 is not enough. 10,000 - hesitate. And then finally N - trust. However, when it was (N-1) - I didn't trust it yet.

The threshold is not defined in absolute value, but as a % of the number who think otherwise. The majority may be wrong, but not 99% is a reliable criterion

 
A100:
And in 1961x32 everything works... yay!

Hmm, interesting feature. I'll specify the platform bitrate from now on too

 
A100:

So? Here:

int i = 1 << 2 + 3;

was the priority mixed up in MQL4 too?

Yes, the documentation says that the priority was different in the old version.

But in my opinion, all this has long since become irrelevant. And all the more so if the strict directive is specified. And if somebody digs up ancient code and tries to compile it, he/she will have to redo a lot of things there anyway. So these warnings are a relic of the past. That's why I agree that you shouldn't throw out warnings in a vacuum.

 
Sorry, if you know, is there any way to get int from void*ptr in mql other than (int)StringFormat("%i",ptr)?
 
A100:

So in your code brackets do not mean anything, the statement ... seems illogical and in case of brackets we need to understand if priorities/order have actually changed, while in my code brackets by themselves mean changing priorities/order (the presence/absence of brackets makes everything clear)

brackets
fxsaber
A100
there's
incomprehensible
priorities of operations are reversed
no
operation priorities have not been changed
the priorities of operations have not been changed

Parentheses make an expression completely unambiguous.

The warnings themselves (not only about parentheses) tell us not about an error, but about the possibility of an error. But you propose to get rid of all the warnings completely, because priorities (not only with parentheses) are clearly specified in the compiler.

A100:

The threshold is not defined in absolute value, but as a % ratio of the number of those who think otherwise. Most may be wrong, but not 99% is a reliable criterion

The same question about the number not in absolute, but in relative. Is 98% a reliable criterion? А 97%? Where is that threshold when you have to start doubting reliability? Even if 100% of everyone around you claims that you are a homicidal maniac. Is that a credible criterion?

 
Ilya Malev:
Sorry for being off-topic, can you tell me if anyone knows: is there any way in mql to get int from void*ptr other than (int)StringFormat("%i",ptr)?

only via strings, I used to get pointer address viaStringConcatenate(), like this:

Cinteger *x = new Cinteger();
   string s;
   int zz=StringConcatenate(s,"*x = ",x);
   Print("OK ",s);
 
Alexey Navoykov:

The most trivial example is the array class. In this case, it is used to store any pointers:

Such an array is of dubious use, frankly speaking. What can you do with it? You know you won't automatically call delete for array members, right?