I\'m a computer science college student. Yesterday, I have a class about Binary Search Tree using C++. We are taught by lab assistants in that class.
They define the nod
It's just undefined behavior.
It appears to work because there's one register that holds the return value. In the deepest paths of the recursion tree, the temp is moved into that register, and never cleared or changed afterwards, so that register will contain the correct node until the first call returns.
When the first call returns, the calling context checks that register for the return value, which happens to be correct. But you shouldn't rely on this. It's not safe to assume it will always work.