Re: break bug
- Posted by jaygade Nov 09, 2012
- 1286 views
bryanso said...
What is the logical motivation or perhaps historical limitation for C to allow fall through in switch statements? It's not intuitive and is a cause of many accidental bugs (at least for me).
I think it has to do with the way the original C code was compiled to assembly/machine language.
I believe that a switch statement usually just compiles into a calculated jump/goto, and each case is just a piece of code that is jumped into. In older memory-constrained computers, you could save some code space by sharing common code between cases.