Path: utzoo!attcan!uunet!dg-rtp!dgcad!aeras!sun!newstop!texsun!texbell!cs.utexas.edu!yale!cmcl2!lanl!lambda!mikeg From: mikeg@c3.c3.lanl.gov (Michael P. Gerlek) Newsgroups: comp.lang.c Subject: Labels as values? Message-ID: Date: 8 Jul 90 17:03:56 GMT Sender: news@lambda.UUCP Distribution: comp Organization: Los Alamos National Laboratory, New Mexico Lines: 30 While modifying someone else's (<-disclaimer) goto-and-label-ridden code, I declared a variable and mistyped it later on -- and my typo happened to be the name of an existing label. Caused no end of mysteries. Simple case: char *ptr; label: ... ptr = (char *)label; ... This code is accepted by both by VAX UNIX and Sun C compilers, but not by gcc (no, I don't have version numbers handy, sorry). I'm certainly no expert, but I'm thinking gcc is right in complaining my use of label in the assignment is invalid since label isn't declared as a variable - if I do declare it, it works fine (even though the identifier 'label' is used in two different contexts). Neither K&R nor Harbison&Steele seem to have anything to say about this. What does the Standard say? Is it legal to use a label as a value-returning construct? And if so, of what type should the label be considered to be? [ M.P.Gerlek (mikeg@lanl.gov) ] [ Los Alamos Nat'l Lab / Merrimack College ] [ Disclaimer: Yes, Mom, I'll play nice. ]