Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!samsung!aplcen!haven!mimsy!mojo!eng.umd.edu!nero From: nero@eng.umd.edu (Oren L. Stern) Newsgroups: comp.lang.c Subject: Type of expression in switch statement Message-ID: <1989Oct30.043155.1931@eng.umd.edu> Date: 30 Oct 89 04:31:55 GMT Sender: news@eng.umd.edu (The News System) Reply-To: nero@eng.umd.edu (Oren L. Stern) Organization: Merriversity of Uniland, College Purgatory Lines: 24 I've had a problem lately using the switch statement. According to K&R on page 202: The switch statement ... has the form switch (expression) statement The usual arithmetic conversion is performed on the expression, but the result must be int. It turns out that where I meant to type "switch (node->tag)", I accidentally typed "switch (node)". Not so surprisingly, cc took it without complaint. However, I went back and lint'ed it and lint took it without complaint as well! I am using the C compiler on a Sparcstation 1 running SunOS 4.0.3. I have written other test programs and it seems both cc and lint allow pointers as expressions in switch statements. Is there something wrong with Sun's compiler, or is there (gasp!) a mistake in K&R? -- Oren Stern | nero@eng.umd.edu Merriversity of Uniland, College Purgatory ----- Disclaimer: I speak only for myself and my evil twin brother, Otto.