Bug report: concerning function arguments/return values.

 

Seems I've tracked down why some of my EA code wasn't working, there's a subtle bug.

I've created a series of overloaded functions to do simple things like find the maximum of two integers.


So, for example, there is one:


uint fn__max( const uint in_a, const uint in_b ) {
   if ( in_a >= in_b ) return( in_a );
   return( in_b );
}

With similar for int, ulong and long, defined in exactly the same way.


The call looks something like:

uint someuint;

...

someuint = fn__max( someuint, someotheruint );

Which does not work as expected, it returns zero.


If some Print() statements are added to the original function,

uint fn__max( const uint in_a, const uint in_b ) {
   Print( "Arguments a,b = ", in_a, ", ", in_b );
   if ( in_a >= in_b ) return( in_a );
   return( in_b );
}

then it works as expected.


I'm not sure whether the MQL5 compiler is optimising something out that it should not be, however without the Print() it doesn't work and with the added Print() it does.  As the semantics are not changed, it must be a compiler issue.

Unsure how to work around it right now as cannot use Print() statements (due to the Championship restriction on log size), so will need to find another way to make it work correctly.  May have to resort to implementing it as a macro (which I probably should have done).  Have implemented it as a macro as it should have been to begin with. 

Anyway, it looks like a bug to me as the function version should still have worked.

 
Thanks for your message. We'll check it.
 

Could you write to ServiceDesk? Please attach an example to reproduce your problem and build number of your terminal.

We've tried to reproduce your problem using description you wrote above but we couldn't. 

 
alexvd:

Could you write to ServiceDesk? Please attach an example to reproduce your problem and build number of your terminal.

We've tried to reproduce your problem using description you wrote above but we couldn't. 


No problem, will do.

 


Odd, I'd copied the relevant code snippets from before and it works correctly.  After the submission date for the Championship, I'll restore one of my backups of the exact file set and see whether it still exhibits the same fault (and whether I have overlooked something).


Reason: