About switch case statements...

bearophile bearophileHUGS at lycos.com
Sun Nov 15 14:58:07 PST 2009


Andrei Alexandrescu

> Link?

If you do a search with Google with:
switch bug "missing break"
Or:
switch bug "fall through"
Or:
switch most common programming bugs

You will see a ton of pages.
Wikipedia says this is a common bug:
http://en.wikipedia.org/wiki/Switch_statement
A bug in Python:
http://bugs.python.org/issue4772
Gcj:
http://gcc.gnu.org/ml/java/2001-12/msg00153.html
Page on C++ pitfalls:
http://www.gauravcreations.com/tutorials/c_pitfalls.html
It's error 825 on Gimpel:
http://www.gimpel.com/html/pub90/msg.txt
Ona page of common C bugs:
http://drpaulcarter.com/cs/common-c-errors.php#2.1
Another in Gcc:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31137
More:
http://pear.php.net/bugs/bug.php?id=5020
http://sourceware.org/ml/gdb-patches/2006-04/msg00234.html
https://savannah.cern.ch/bugs/?15576
http://aspn.activestate.com/ASPN/Mail/Message/php-Dev/901756
http://opensource.atlassian.com/projects/hibernate/browse/HHH-448
A page that warns again them:
http://www.jaggersoft.com/pubs/CVu09_1.html
Listed by Linus:
http://lkml.org/lkml/2005/9/30/219
Java findbugs is supposed to find them:
http://osdir.com/ml/java.findbugs.general/2005-01/msg00020.html
In boost:
http://www.boost.org/doc/tools/jam/jam/history.html

If you keep searching you can find a good amount of them.
It's not the most common kind of bug, but it seems common enough to deserve warnings, lints, several pages of "C/C++ traps & tricks", etc.

There is also a well know bug by AT&T, but it's a little different:
http://www.gowrikumar.com/blog/2009/01/06/att-break-bug/

Bye,
bearophile



More information about the Digitalmars-d mailing list