Article View: gnu.g++.bug
Article #561Re: scope of enumerators
From: Thant Tessman
Date: Mon, 13 Nov 1989 17:16
Date: Mon, 13 Nov 1989 17:16
36 lines
1551 bytes
1551 bytes
In article <2113@isaak.isa.de>, schwarze@isaak.isa.de (Jochen Schwarze) writes:
>
> Consider the following:
>
> struct color {
> enum { red, green, blue } type;
> };
>
> main()
> {
> struct color favourite;
>
> favourite.type = red;
> }
>
> If this piece of code is compiled with g++ (1.35.0) or AT&T cfront (1.20)
> both compilers complain about `red' in line 10 being undefined or
> undeclared, resp.
>
> gcc (1.35.0) and Sun cc compile without problems.
>
In _Programming in C++_ by Dewhurst and Stark, on page 60 it mentions
that 'enum' can be nested within a class. Although it doesn't outright say
it, I would think that this implies that 'enum' scopes like anything else.
I have used 'enum' this way (i.e. assuming it scopes) and I find it very
usefull
for making code more readable (and more typesafe, because C++ (2.0) actually
typechecks enums as separate types).
I would think gcc and Sun cc are busted.
thant
There are 336 dimples on the standard golf ball.
Technical Details
Message-ID:
<1404@odin.SGI.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!gem.mps.ohio-state.edu!ctrsol!lll-winken!arisia!sgi!shinobu!odin!horus!thantReferences:
<2113@isaak.isa.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!gem.mps.ohio-state.edu!ctrsol!lll-winken!arisia!sgi!shinobu!odin!horus!thant From: thant@horus.sgi.com (Thant Tessman) Newsgroups: gnu.g++.bug,comp.lang.c++ Subject: Re: scope of enumerators Message-ID: <1404@odin.SGI.COM> Date: 13 Nov 89 17:16:12 GMT References: <2113@isaak.isa.de> Sender: news@odin.SGI.COM Reply-To: thant@horus.sgi.com (Thant Tessman) Distribution: gnu, world Organization: Silicon Graphics, Inc. Lines: 36