Very different behaviour when compiler is set to Maximum Optimisation vs No Optimisation (MQL5 build 4040)

 

I am building an EA and am experiencing some very odd behaviour in the MQL5 compiler, debugger and strategy tester.

When I run my code in the debugger, or compile with No Optimisation, it works correctly and as expected. However, when I compile with optimisation enabled it runs very strangely and produces wrong results. I suspect this is a compiler bug and am unsure how to investigate it.

Any Ideas that might help?

 

"Odd behaviour", "strangely"...are serious ? This is a technical forum !

What you need to do is to investigate it correctly

 
Alain Verleyen #:

"Odd behaviour", "strangely"...are serious ? This is a technical forum !

What you need to do is to investigate it correctly

"Odd behaviour" = completely different results when compiler optimisation is on or off. This should not happen and has never happened before.

It turns out this was a bug in the build 4040 compiler, that appears to be fixed in 4073 beta. Normal behaviour (i.e. identical behaviour with/without full optimisation) is back.

Thank you for your kind help. I am not stupid and quite an experienced developer, and it if a compiler misbehaves it is extremely difficult to investigate, for obvious reasons.

 
Alain Verleyen #:

"Odd behaviour", "strangely"...are serious ? This is a technical forum !

What you need to do is to investigate it correctly

You apparently did not read my post. I suggest you do that before being rude..

 

You can be sure I read all.  99% of MT5 or mql5 compiler "bugs" reported on this forum turns on to be "user bugs". Instead of being offended, as I experienced developer, you should know how to report a bug if you want an useful answer. We don't have to believe anything just because you think there is a bug.

I checked with an EA which is rather complex and I got the exact same results using "No Optimization" or "Maximum Optimization". The only difference is the execution time, obviously.

So we still don't have a clue what you are talking about.

 
Alain Verleyen #:

You can be sure I read all.  99% of MT5 or mql5 compiler "bugs" reported on this forum turns on to be "user bugs". Instead of being offended, as I experienced developer, you should know how to report a bug if you want an useful answer. We don't have to believe anything just because you think there is a bug.

I checked with an EA which is rather complex and I got the exact same results using "No Optimization" or "Maximum Optimization". The only difference is the execution time, obviously.

So we still don't have a clue what you are talking about.

It's very simple: with exact same code that has always produced identical results (apart from speed as you so perceptively point out) on No Optimisation and Maximum Optimisation, on build 4040 of the compiler the output and behaviours were wildly different. Once I upgraded to build 4073 beta the normal behaviour returned.

So yes, it was a compiler bug.

Thank you again for all your help.

Reason: