Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!jarthur!jseidman From: jseidman@jarthur.Claremont.EDU (James Seidman) Newsgroups: comp.lang.c Subject: Re: problems/risks due to programming language Message-ID: <4611@jarthur.Claremont.EDU> Date: 24 Feb 90 01:15:16 GMT References: <2903@goanna.oz.au> <12134@goofy.megatest.UUCP> Organization: Harvey Mudd College, Claremont, CA 91711 Lines: 28 In article <12134@goofy.megatest.UUCP> djones@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.