digitalmars.D.learn - Infinite loop (again)
- Cecil Ward (25/25) Jun 30 2023 Some while ago, I posted about the possibility of detecting
Some while ago, I posted about the possibility of detecting straightforward infinite loops. I thought I that was that. Due to my own stupidity I’ve now hit yet another one due to forwarding overloaded functions incorrectly. I messed up the argument list, basically. This did happen to be because of infinite recursion, but it was tail-end optimised to a null-body infinite loop, so no stack overflow. So a compiler’s check that is does not involve recursion would catch recursive infinite loops and straight loops in this case. Even just the one case, in pseudo-asm: foo: jmp foo would be very worthwhile as yet again I wasted too much time debugging this idiocy that is happy to run with no warnings. This was a loop that after code generation has no body at all. It would be a really really worthwhile error message given that I cannot be the only fool out there. Well, mind you … ;-) I would beg the compiler writers to implement this error message which is straightforward in the back end. 1. Nearer to the front end, recursion with no escape branch is obviously not good. 2. Loops that have no escape route branches and whose body is either null or which contain no side-effects are also not good 3. I would settle for just straightforward null-body infinite loops checked in the back end if that is possible. Never mind recursion for the moment.
Jun 30 2023