https://issues.dlang.org/show_bug.cgi?id=14419
--- Comment #16 from Jens Bauer <[email protected]> --- (In reply to Iain Buclaw from comment #15) > So then you just need to decide what is a suitable iteration limit, > short.max? ushort.max? If it's just to make sure that "we're not stuck forever", the size of the returned argument might be suitable. I believe this is very much a matter of opinion, though. But consider this. Combining with my previous idea of checking the exit-conditions. All sources for the exit-conditions should be saved (the stack would be fine): All minimum values for the exit conditions All maximum values for the exit conditions A minimumHit counter A maximumHit counter Each time the same minimum for all exit conditions are hit, then the minimumHit counter is incremented. If a new minimum is found, the minimumHit counter is cleared. Same thing for the maximumHit counter. Now if any of those two counters reach a value above - say 10, then we'll exit the loop. As a fail-safe, an unsigned 32-bit counter could be used as an 'absolutely maximum limit'. This is just an idea, but I believe it would be fairly good at catching more than 99% of the lockups. --
