Features of the mql5 language, subtleties and tricks - page 249

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Probably because the compiler does unrole and reduces it to a single assignment line....
Replacing it with MathRand, which logically is never called, makes a non-zero value. This further supports the hypothesis that zero is a compiler error.
Then it's a compiler error.
Replacing it with MathRand, which logically is never called, makes a non-zero value. This further supports the hypothesis that zero is a compiler error.
Why?
Why?
How do you know it will be initialised? Won't it just be filled with values? Or is that what you mean by "initialised".
I don't know, I'm relying on the docs. It says that the structure must be filled. But if a value is not assigned to a field in the function being called, we get a UB when we get the value of that field later.
Tried it.
Result.
Frankly speaking, I don't understand why the second line gets zero when there is no initialisation.
This is UB behaviour. Since you return the value of the field, the compiler thinks you have initialised it, the only place where you do that is
Tick.time = 1;
Accordingly, your entire function is reduced by the optimiser to
It doesn't. For example, swap the Bench1 and Bench2 calls.
This is the behaviour under UB. Since you return the value of the field, the compiler assumes you have initialised it, the only place you do that is
Consequently, your entire function is reduced by the optimiser to
Parity.