Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cs.utexas.edu!rutgers!rochester!uhura.cc.rochester.edu!sunybcs!bingvaxu!leah!itsgw!steinmetz!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.bugs.4bsd Subject: Re: strange effects with enumerated types Keywords: enum,courier Message-ID: <20@auspex.UUCP> Date: 19 Oct 88 01:26:46 GMT References: <142@csaran.cs.tcd.ie> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 28 >why does the compiler (I don't know which compiler it is. I assume it is >the standard one supplied with a SUN 3/50) ...which is based on PCC or its descendants, like many (most?) UNIX C compilers, so I suspect this bug may exist in other UNIX C compilers as well... >produce this result and is it a bug of this compiler or a "feature" of C ? According to K&R, second edition (which includes stuff from a recent ANSI C draft): Enumerator names in the same scope must all be distinct from each other and from ordinary variable names, but the values need not be distinct. I infer from K&R 2 that the scope of the "enum" in "new_struct" is the entire source file and the scope of the "enum" in "*p" to be the function "test_fn1". Now, K&R 2 also says If an identifier is explicitly declared at the head of a block, including the block constituting a function, any declaration of the identifier ouside the block is suspended until the end of the block. From that, I infer that the declaration "a", "b",and "c" in the definition of "new_struct" should be suspended inside the block constituting "test_fn1", so that this is a compiler bug.