Article View: gnu.gcc.help
Article #53260Re: Does gcc 2.0 support computed gotos?
From: John F. Woods
Date: Fri, 21 Feb 1992 21:23
Date: Fri, 21 Feb 1992 21:23
28 lines
2042 bytes
2042 bytes
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.)
>Judging from the email I've gotten, apparently I was too concise. I *KNOW* gcc
>(sometimes) makes a dispatch table internally. However, it makes sure that
>the index into that table (based on the switch #) references something in that
>table. This is how it skips case's not explicitly handled by the switch and
>higher than the highest case number. This is perfectly reasonable behavior.
>However, in my situation can guarantee that the X in the switch (X) will
>always be handled by some case statement, so I don't want the internal bounds
>check. Unfortunately, I've been unable to coerce gcc into avoiding the check.
A better approach would be something on the order of
#pragma nocheck
switch(x) {
case ...
I have used a compiler which has a command-line flag to tell it that switches
need not perform bounds checking, but a #pragma to do it with statement scope
instead of file scope would be better. Also, it leaves your code looking more
like ANSI C instead of MUTANT C.
Technical Details
Message-ID:
<10012@ksr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!world!ksr!jfwReferences:
<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-21 21:55:52 PST Path: arc1-ca.pugleaf.net!sparky!uunet!world!ksr!jfw From: jfw@ksr.com (John F. Woods) Newsgroups: gnu.gcc.help Subject: Re: Does gcc 2.0 support computed gotos? Message-ID: <10012@ksr.com> Date: 21 Feb 92 16:23:06 EST References: <1992Feb21.023817.17703@athena.mit.edu> <1992Feb21.033356.18370@athena.mit.edu> Sender: news@ksr.com Lines: 29