problems/risks due to programming language

James Seidman jseidman at jarthur.Claremont.EDU
Sat Feb 24 12:15:16 AEST 1990


In article <12134 at goofy.megatest.UUCP> djones at megatest.UUCP
(Dave Jones) writes:
>    proc()
>    { enum bar foo;
>       switch(foo) {
	[program parts deleted]
>       boom:
>          do_the_other();
>          break;
>       }
>     }
>(The cases were separated by more lines of code.) The compiler loved
>it. Sun's cc allows this if the enumeration is declared globally, but
>not if it is declared within a block, if I remember correctly.

I think, unfortunately, that this is in fact correct code.  It is,
ironically, a "labeled statement," the kind used with goto.  I'm not sure
about why Sun's cc doesn't allow this if the enumeration is declared within
a block, though.  Under ANSI, labels have their own name space which is
independent of enumerations and the like.  I get the impression, though,
that this is not very well standardized on pre-ANSI compilers.  Labeled
statements inside a case statement would be a nice addition to lint,
though.
-- 
-------------------------------------------------------------------------------
Jim Seidman, Harvey Mudd College, Claremont, CA 91711.  (714) 621-8000 x2026
DISCLAIMER: I don't even know if these are opinions, let alone those of
            anyone other than me.



More information about the Comp.lang.c mailing list