>I've had the joy of seeing code which broke completely if you removed the line while(false){}. Some hideous synchronization bug was solved by this line, and while it obviously wasn't the right solution, simply deleting it produced bad outputs. Profilers and processing tools are, as you say, other likely causes of dumb-looking code choices.
I've had a few compiler bugs where, adding an if false or changing the order of an if test 'fixes' things. And the complement changing the code exposes a compiler bug. And also, new improved compiler results in code that's broken.
Other issues I run into a fair amount is dealing with hardware/naked interrupts often involves a lot of subtle timing and read/write access issues. Sometimes this happens in code you don't own.
Oh, come on, that's an obvious one. Obviously, "removing the while(False) loop" in this case means replacing it with an empty return:
def stub():
return
print("hello, world")
stub()
There, it works.
That said, boo Python for not admitting empty bodies. It needlessly adds a special case to its syntax. I suspect this comes from the implementation of its lexer.
The question I answered was: "How is this even possible?" (emphasis in the original). The implication seems to be that it should not be possible for the removal of a `while(False)` statement to break working code, presumably based on the assumption that it can't do anything. Yet that is a false assumption, and lots of bugs are based on assumptions that seem true yet, strictly speaking, don't have to be. I provided an existence proof that it IS possible and one minimal example that the assumption that such code literally can't play any role in whether code works or not is incorrect.
Okay, how is this even possible? Reflection/pre-processing magic?