Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-adm!brl-smoke!smoke!dietz%slb-doll.csnet@CSNET-RELAY.ARPA From: dietz%slb-doll.csnet@CSNET-RELAY.ARPA (Paul Dietz) Newsgroups: net.lang.c Subject: Unchecked Switch Statement Message-ID: <1706@brl-smoke.ARPA> Date: Tue, 11-Mar-86 17:59:25 EST Article-I.D.: brl-smok.1706 Posted: Tue Mar 11 17:59:25 1986 Date-Received: Fri, 14-Mar-86 06:48:17 EST Sender: news@brl-smoke.ARPA Lines: 12 This issue has probably been discussed before, but here goes... There seems to be an philosophical difference in C between array accesses and switch statements. In array accesses the compiler is free to generate code that does undefined things if the index is out of bounds. In contrast, switch statements must fall through if there is no "default:" label and no "case" matches the switch expression. A more consistent definition would have the compiler generate code that checks for an out-of-bounds switch expression only when a default label is present. The default label could be placed last in the switch statement to get the same behavior as current default-less switches.