Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!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: What happened to label variables? Message-ID: <1418@brl-smoke.ARPA> Date: Fri, 28-Feb-86 18:06:51 EST Article-I.D.: brl-smok.1418 Posted: Fri Feb 28 18:06:51 1986 Date-Received: Mon, 3-Mar-86 00:35:44 EST Sender: news@brl-smoke.ARPA Lines: 28 I recall that C on early UNIX's treated labels as constants of type (int *). As a result, you could assign labels to variables and even jump to the label in a variable. This got taken out of K&R, and as I far as I can tell it's not in other C's today. This is unfortunate; I ran into a situation recently in which I wanted to (automatically) generate C code that should, for efficiency reasons, contain label variables. I had to simulate them with a switch statement of the form: switch(labelindex) { case 1: goto label1; case 2: goto label2; ... case n: goto labeln; default: fprintf(stderr,"unknown label index: %d\n", labelindex); abort(); } This is a lot slower, though, and some of the compiler's I tried it on (the VAX VMS C compiler, for example) did not peephole optimize the jump table implementing the switch and the branch instructions implementing the goto's (this should have been treated as a jump to a jump). I'm curious if any commerically available C compilers implement jumps to arbitrary pointers without recourse to assembly language inserts.