rainer@boulder.Colorado.EDU (Rainer Malzbender) (03/27/91)
I inadvertently typed "case_3:" instead of "case 3:" in a 'switch' statement. Now I'm certainly no guru on the arcane features of the C language, but shouldn't this be illegal and at least cause a compiler error? My program compiled and ran fine. As far as I can tell from the .s output (I don't grok R3000 assembler) it just trashed the whole clause. -- Rainer Malzbender, PhD "It's not the bullet that kills you, it's the hole." Dept. of Physics (303)492-6829 -Laurie Anderson U. of Colorado, Boulder rainer@boulder.colorado.edu 128.138.240.246
rainer@boulder.Colorado.EDU (Rainer Malzbender) (03/27/91)
Thanks to all who pointed out my stupidity. Of course it's a label. I don't think I've ever actually used one in a C program, so it didn't occur to me. More sleep is perhaps in order. Thanks for the quick response. -- Rainer Malzbender, PhD Eating a lot of crow lately. Dept. of Physics (303)492-6829 U. of Colorado, Boulder rainer@boulder.colorado.edu 128.138.240.246
sweetmr@SCT60A.SUNYCT.EDU (michael sweet) (03/27/91)
> I inadvertently typed "case_3:" instead of 'case 3:' in a 'switch'... > ... Actually, you made a 'goto' label by doing that! As for trashing the 'case 3' block of code, the optimizer probably saw that it wasn't being used and removed it... -Mike
subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (03/27/91)
In article <1991Mar26.235622.20057@colorado.edu> rainer@boulder.Colorado.EDU (Rainer Malzbender) writes: >I inadvertently typed "case_3:" instead of "case 3:" in a 'switch' >statement. Now I'm certainly no guru on the arcane features of the >C language, but shouldn't this be illegal and at least cause a >compiler error? My program compiled and ran fine. As far as I can tell >from the .s output (I don't grok R3000 assembler) it just trashed >the whole clause. Realize that ':' also stands for a label in C, and so your case_3: statement was treated as a label, where later in the program you could possibly say "goto case_3". Certainly not what you intended, but nevertheless quite legal. -Kartik -- internet# find . -name core -exec cat {} \; |& tee /dev/tty* subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet