The Metal spec says that recursive functions are not allowed. However this compiles fine:
int b(int c) {
if (c == 1)
return b(c++);
else if (c == 2)
return b(c + 2);
else
return c;
}
Why is that? What is the definition of recursive that Metal is using? It refers to section 5.2.2 of the C++14 spec, which also does not give any definition of "recursive" thus I'd expect the above to be a standard example of recursion.
Even if I do this, it still compiles:
int b(int c) {
return b(c + 2);
}
What gives?!
The function can compile fine like any C++ function, no problem. It's when you call the function from a kernel that you will get a compile error about recursive function use.