Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site yetti.UUCP Path: utzoo!utcs!mnetor!yetti!oz From: oz@yetti.UUCP (Ozan Yigit) Newsgroups: net.lang.c Subject: case stmt != jumptable of goto labels !!!!!!!!! Message-ID: <324@yetti.UUCP> Date: Thu, 20-Feb-86 10:57:25 EST Article-I.D.: yetti.324 Posted: Thu Feb 20 10:57:25 1986 Date-Received: Thu, 20-Feb-86 13:28:11 EST Reply-To: oz@yetti.UUCP (Ozan Yigit) Organization: York University Computer Science Lines: 44 Keywords: case, jumptable Why is it, when someone asks whether or not jumptables with goto labels are allowed in C, there is the overwhelming response "use a case statement" ???? It is not the same, except in one isolated circumstance, where the user-created jumptable is completely static. Furthermore: [1] You are never guaranteed to get a jumptable out of a case statement. If you get it with compiler X, you may not get with compiler Y. [the reason may be a buggy implementation or whatever, but would be unnoticable, since it does not effect the correctness of the generated code] [2] The structure of the case jumptable may be different from compiler to compiler. [Vaxen Cc may generate a jump table of relative offsets to feed to case[wl] instruction, whereas others may generate a table of direct addresses] [3] The jumptable is hidden, thus cannot be manipulated. (unless, of course, you are practicing black magic :-) I can see some weird application where a jumptable of goto labels is used, and program dynamically alters the control flow by swapping labels on the jump table, or by adding new ones in. Surely this would be most unreadable, and difficult to debug, and something I would classify as "pornographic programming", but than, It is proven nicely in "obfuscated C" contests that one can do a lot worst. Please hold your flame, in case you are ready to lit. I am not suggesting that C should have the capability, [Although it is certainly debatable] nor am I suggesting that a jumptable with goto labels is necessary, where jumptables with function entries could easily be created. All I am arguing against is the unthinking suggestion that case == jumptable of labels. Oz -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] FREE SOFTWARE FOUNDATION vs. EMPIRE. Watch for things to come..