Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!orion.cf.uci.edu!paris.ics.uci.edu!bonnie.ics.uci.edu!schmidt From: schmidt@bonnie.ics.uci.edu (Douglas C. Schmidt) Newsgroups: comp.lang.c Subject: Explanation, please! Message-ID: <638@paris.ICS.UCI.EDU> Date: 25 Aug 88 02:16:14 GMT Sender: news@paris.ics.uci.edu Reply-To: schmidt@bonnie.ics.uci.edu (Douglas C. Schmidt) Organization: University of California, Irvine - Dept. of ICS Lines: 36 References: The following piece of wonderful obscurity comes from Stroustup's C++ Programming Language book, page 100: void send(int *to,int *from, int count) { int n = (count + 7) / 8; switch(count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while (--n > 0); } } Now, much to my surprise, this is not only valid C++, it is also valid C! Could some one please explain to me why this is so? It seems like the case 7-1 labels are actually nested inside the do {} while loop, and thus not in the scope of the switch (should a break statement exit both the switch and the loop, or just one?!?!). Finally, Stroustrup asks the rhetorical question ``why would anyone want to write something like this.'' Any guesses?! thanks, Doug Schmidt -- Douglas Schmidt "If our behavior is strict, we do not need fun." -Zippy th' Pinhead "If our behavior is struct, we do not need defun." -Anon