Select Float - Both A and B are evaluated?

Given this in an empty new project, in the level blueprint :


I get a Divide by zero warning in the log, which means both A and B were evaluated, whereas only A should have been (or so would seem logical to me, at least).


An actual situation where MyArray == 1 :


It returns the divide by zero warning, but it shouldn’t?

It’s not a critical issue, but imagining A and/or B having a complex calculation, it seems like a waste of resources having both being evaluated if only one is necessary?

Is that intended or should it be reported as a bug?

Looking at the source code:

float UKismetMathLibrary::SelectFloat(float A, float B, bool bSelectA)
return bSelectA ? A : B;

To call this function, you have to send float A, float B, and the bSelectA, and then it returns the result. To send float A and B into the function, you must first evaluate them. So yes, this should be happening.

A compiler doesn’t know if only one is needed.
Your “select” boolean can be true or false at runtime.