Re: break bug

new topic     » goto parent     » topic index » view thread      » older message » newer message
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.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu