Just to understand: overloaded function resolution happens at compile time, and the sample code is 'deterministic' with respect to EMA(). Why would it then be 'undefined' behavior?
Btw: if the 2nd parameter is an int, rather than a var, all works fine...