🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53300

Re: Does gcc 2.0 support computed gotos?

#53300
From: Skip Gilbrech
Date: Wed, 26 Feb 1992 07:19
45 lines
2041 bytes
In article <1992Feb21.033356.18370@athena.mit.edu> mjhostet@slayer.mit.edu (Mat Hostetter) writes:

>In article <1992Feb21.023817.17703@athena.mit.edu> mjhostet@slayer.mit.edu (Mat  
>Hostetter) writes:
>> I saw in the GNU status report that "C has been extended to support
>> nested functions, nonlocal gotos, and taking the address of a label."
>> 
>> Will there be any way to have an array of label-pointers and dispatch to the  
>> one I want?  (eg, "goto label_array[x]".)  (I basically need a switch that  
>does  
>> no bounds checking, for a really speed-intensive loop.)
>> 
>> -Mat

This looks kind of like what you want, no?

I just got gcc 2.0 built and tried it... The code isn't pretty
but works like a charm....

Check out: gcc.info,  Node: Labels as Values.

-Skip

main()
{
    static void *array[] = { &&lab0, &&lab1, &&lab2, &&lab3, &&lab4 };
    int i = 5;

top_loop:
    if (--i < 0)
	exit(0);

     goto *array[i];

lab0:	printf("lab0\n"); goto top_loop;
lab1:	printf("lab1\n"); goto top_loop;
lab2:	printf("lab2\n"); goto top_loop;
lab3:	printf("lab3\n"); goto top_loop;
lab4:	printf("lab4\n"); goto top_loop;
}
-- 
Skip Gilbrech			email:	skip@fsg.com
Fusion Systems Group			uupsi!fsg!skip
225 Broadway, 24th Floor		uupsi!skipnyc!skip
New York, NY 10007		phones:	212-285-8001 (work)
Technical Details
Message-ID: <SKIP.92Feb26021948@skipsun.skipnyc>
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!fsg!skipsun!skipsun!skip
References: <1992Feb21.023817.17703@athena.mit.edu> <1992Feb21.033356.18370@athena.mit.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,5fb12b206120b8ea
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-02-26 05:47:56 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!fsg!skipsun!skipsun!skip
From: skip@skipnyc (Skip Gilbrech)
Subject: Re: Does gcc 2.0 support computed gotos?
In-Reply-To: mjhostet@slayer.mit.edu's message of Fri, 21 Feb 1992 03:33:56 GMT
Message-ID: <SKIP.92Feb26021948@skipsun.skipnyc>
Lines: 40
Sender: skip@skipnyc (Skip Gilbrech)
Organization: Fusion Systems Group, New York City
References: <1992Feb21.023817.17703@athena.mit.edu> <1992Feb21.033356.18370@athena.mit.edu>
Date: 26 Feb 92 07:19:48 GMT