Article View: comp.lang.c
Article #237Re: Taming The Switch-Statement
From: Lawrence D’Oliveiro
Date: Sun, 11 Oct 2026 21:12
Date: Sun, 11 Oct 2026 21:12
54 lines
4450 bytes
4450 bytes
On 11 Oct 2026 10:14:15 GMT, Stefan Ram wrote: > On Sat, 10 Oct 2026 22:58:15 -0000 (UTC), Lawrence D’Oliveiro wrote: > >> On Sat, 10 Oct 2026 15:30:54 -0700, Andrey Tarasevich wrote: >> >>> But `break` and `continue` behave differently inside `switch` in >>> C: the former can "see" the enveloping `switch` statements, while >>> for the latter all enveloping `switch` statements are completely >>> transparent. So, in order to refer to the same cycle one'd have to >>> use different nesting numbers in `break` and `continue` when used >>> inside `switch`(-es) in C. That would look quite confusing. >> >> It also led to a major real-world calamity: the Great AT&T >> Telephone Crash of 15th January 1990. To quote from Bruce >> Sterling’s “The Hacker Crackdown”: >> >> As it happened, the problem itself -- the problem per se -- >> took this form. A piece of telco software had been written in C >> language, a standard language of the telco field. Within the C >> software was a long "do... while" construct. The "do... while" >> construct contained a "switch" statement. The "switch" >> statement contained an "if" clause. The "if" clause contained a >> "break." The "break" was *supposed* to "break" the "if clause." >> Instead, the "break" broke the "switch" statement. >> >> Back at the time, law enforcement was just cottoning on to the idea >> that evil people could use their technical skills with computers to >> wreak havoc with all kinds of crucial infrastructure. AT&T figured >> out, within nine hours, that the problem here was purely a mistake >> in their software, but it took somewhat longer for some authorities >> to be disabused of the notion that this was intentional sabotage. >> >> <http://web.archive.org/web/20031204221934/www.chriswaltrip.com/sterling/> > > Assuming a "break" will leave an "if" in C is an error of someone > who has not learned C yet ... These were C experts -- they were software engineers working at AT&T after all. Bear in mind Bruce Sterling is not a C expert, or even a programming expert. I have looked at several descriptions of the nature of the bug, and I couldn’t find any (to link to) that were any better than his. The most natural interpretation I can think of is that the break statement wasn’t supposed to cut short the if-statement as such; it was meant to terminate a surrounding loop. That would have worked, except that this particular break-statement was inside a switch-statement in that loop, so all it did was cut short the switch-statement. I think the surrounding loop was then left to repeat endlessly without reaching any exit condition, which was the cause of the failure.
Technical Details
Message-ID:
<11agu3m$30k5e$3@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me> <11addhr$1oakb$1@dont-email.me> <11aduuk$cjlv$1@dont-email.me> <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me> <11aeeau$24vgh$1@dont-email.me> <11aefu7$254m6$1@dont-email.me> <FlByS.11178$mPXe.3035@fx06.ams4> <break-20261011111215@ram.dialup.fu-berlin.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence D’Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Sun, 11 Oct 2026 21:12:23 -0000 (UTC) Organization: A noiseless patient Spider Lines: 54 Message-ID: <11agu3m$30k5e$3@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me> <11addhr$1oakb$1@dont-email.me> <11aduuk$cjlv$1@dont-email.me> <20261010220212.000063fd@yahoo.com> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me> <11aeeau$24vgh$1@dont-email.me> <11aefu7$254m6$1@dont-email.me> <FlByS.11178$mPXe.3035@fx06.ams4> <break-20261011111215@ram.dialup.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 11 Oct 2026 21:12:23 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3166382"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hY/yNzTe42Hj6/D8j5zex"; posting-host="a82cbb4a9e343247fd3ed93594ed57ba" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:uyv4WDeQSIzK0y42ti+fk+Ctz14= sha256:4jSomh7Dwz69qYChByl1YOCCnYkQS5hHt5IGUIY09Oo= sha1:5wzL9imYnOrmXwEVG+i0B/Ify/A= sha256:K6o1UFYsKPOpjLnbxqU087UNTk7qR1Vr6/9SwQvAqs0=