So I have a simple recursive function that returns the number of places to the left of the decimal point of a float, it looks like this:
int32 CalcTenPlaces(float Num)
{
if (Num > 10)
{
return CalcTenPlaces(Num / 10) + 1;
}
return 1;
}
When I try to build my project with this function in it, I get this error: “error C4718: ‘CalcTenPlaces’ : recursive call has no side effects, deleting.” I looked it up, and according to this, I should only get that error if the recursive function call do anything which would overflow the stack. The thing is, I tested an identically written function in Steel Bank Common Lisp on my ARM processor Chromebook with less than a 16th of the RAM on the machine that I develop for, and not even ridiculously big values would overflow the stack, values that can’t even be stored in an int32 (the last value I tested was 11298 digits long according to the function). So why doesn’t it work in UE4? Are recursive functions not allowed in UE4 C++, is this function actually likely to overflow the stack in UE4? I rewrote the function to calculate the value using iteration, I am just curious at this point.