Article View: gnu.g++.bug
Article #945Problem with class-local enum declarations in g++ 2.2.2
From: Jens P. Brage
Date: Fri, 11 Sep 1992 14:06
Date: Fri, 11 Sep 1992 14:06
50 lines
2837 bytes
2837 bytes
Hi.
I think I've found a bug in g++ 2.2.2: Class-local enumerations cannot be
addressed from within another class:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
class ClassA
{
public:
enum AnEnumeration { Enum1, Enum2 };
};
ClassA::AnEnumeration Var1;
class ClassB
{
ClassA::AnEnumeration Var2;
};
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The declaration of Var1 is accepted, but the declaration of Var2 produces the
error:
> Test.cxx:12: class-local enum declaration `AnEnumeration' is not in scope here
As far as I can see, this should be legal according to r.7.2 of Bjarne
Stroustrup's "The C++ Programming Language". The problem may be related to
another problem with class-local enums I've reported before:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
class ClassA
{
public:
enum AnEnumeration { Enum1, Enum2 = Enum1 };
};
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
In this case, Enum1 is unknown at the point of declaration of Enum2. This works
if the enumeration isn't embedded in a class.
Version info: I'm running on a Sun Sparc SLC with SunOS 4.1, "g++ -v" gives:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix Test.cxx /usr/tmp/cca16047.i
GNU CPP version 2.2.2 (sparc)
/usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca16047.i -quiet -dumpbase Test.cc -version -o /usr/tmp/cca16047.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--
Jens P. Brage (jpb@id.dth.dk)| Between those in constant power and those in
Design Automation Group |constant pain. Between those who run to glory
Center of Integrated Electronics|and those who cannot run. Tell me, which ones
Technical University of Denmark |are the cripples and which ones touch the sky?
Technical Details
Message-ID:
<1992Sep11.160612@dc.dth.dk>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ideal.id.DK!brageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ideal.id.DK!brage From: brage@ideal.id.DK (Jens P. Brage) Newsgroups: gnu.g++.bug Subject: Problem with class-local enum declarations in g++ 2.2.2 Message-ID: <1992Sep11.160612@dc.dth.dk> Date: 11 Sep 92 14:06:12 GMT Sender: gnulists@ai.mit.edu Reply-To: brage@ideal.id.dk (Jens P. Brage) Distribution: gnu Organization: Dept. of Computer Science, Technical University of Denmark Lines: 50 Approved: bug-g++@prep.ai.mit.edu