Labels as values?

diamond@tkovoa diamond at tkou02.enet.dec.com
Tue Jul 17 10:38:04 AEST 1990


In article <MIKEG.90Jul8110356 at c3.c3.lanl.gov> mikeg at c3.c3.lanl.gov (Michael P. Gerlek) writes:

>Simple case:
>	char *ptr;
>	label:
>	...
>	ptr = (char *)label;

According to the standard, an identifier is a primary (expression) if the
identifier designates an object or function.  A label does not designate
an object or function.  However, this is not in a constraints section or
syntax, so if a processor provides an extension for this, it is not required
to issue a diagnostic (unfortunately).

Label space is separate from ordinary identifier space.  So if you also
have an ordinary identifier (e.g. object, function, or typedef) also named
"label", then the processor must use the correct "label" in that expression
(i.e. not the label "label").  (Of course, if your ordinary identifier is a
typedef name, then the expression will be illegal for other reasons.)

The unwanted extension that was granted by several processors is even more
dubious, because the value assigned to "ptr" changes when you declare a
variable also named "label".  When the standard assigns a meaning to a
construct, a processor is not allowed to wave some extension and decide
that you get a different meaning.
-- 
Norman Diamond, Nihon DEC     diamond at tkou02.enet.dec.com
This is me speaking.  If you want to hear the company speak, you need DECtalk.



More information about the Comp.lang.c mailing list