This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3526: ICE on inherited enum

>Number:         3526
>Category:       c++
>Synopsis:       ICE on inherited enum
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 02 01:46:01 PDT 2001
>Originator:     Kurt Garloff
>Release:        3.0.1 20010701 (prerelease)
SuSE GmbH Nuernberg
System: Linux 2.4.3-p7-amp-SMP #37 SMP Tue Apr 24 00:19:58 CEST 2001 i686 unknown
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --with-gcc-version-trigger=/raid/egcs/gcc/version.c --host=i686-pc-linux-gnu --with-system-zlib --with-gnu-ld --with-gnu-as --enable-libstdcxx-v3 --prefix=/raid/gcc300 --enable-haifa --enable-threads=posix : (reconfigured)  : (reconfigured) ../configure --with-gcc-version-trigger=/raid/egcs/gcc/version.c --host=i686-pc-linux-gnu --with-system-zlib --with-gnu-ld --with-gnu-as --enable-libstdcxx-v3 --prefix=/raid/gcc300 --enable-haifa --enable-threads=posix
	g++ 3.0.1 (prerelease) gives a strange error message
	(tells me to replace the declaration with the words
	 that I'm actually using) and then dies with an Internal
	Error (SIGSEGV).
garloff@pckurt:~/C > g++ -c inherited_enum.cpp 
inherited_enum.cpp:31: warning: enum typename test2<T>::MyEnum' declares a new 
   type at namespace scope;
   to refer to the inherited type, say enum test2::MyEnum'
   (names from dependent base classes are not visible to unqualified name 
inherited_enum.cpp:31: Internal error: Segmentation fault
   Please submit a full bug report,
	Notes: gcc-2.95 dies with an ICE as well (though without
		the error message before.)
	       DEC CXX does compile the code.
	Compile this program:

/** \file inherited_enum.cpp
 * Both gcc-2.95.3 and gcc-3.0.0 produce an ICE on this code.
 * Note: Using a typedef does solve the problem.
 *       Using the keyword typename does not help.
 * The syntax test1<T>::MyEnum produces the same ICE.
 * However, gcc-3.0.0 suggested using test2::MyEnum.
 * Doing so, gcc-3.0.0 still complains that test2::MyEnum should be used.
 * Afterwards: Internal Error: Segmentation Fault
 * I (and DEC's CXX) believe the code is legal, but I can't tell for sure.
 * (w) Kurt Garloff <>, 2001-06-27, (c) GNU GPL

template <typename T>
class test1 
	test1 (int i) { if (i==0) m_en = EN0; else m_en = EN1; };
	enum MyEnum { EN0, EN1, EN2, EN3 };
	MyEnum m_en;

template <typename T>
class test2 : public test1<T>
	test2 (int i, int j) : test1<T>(i) {if (j==0) m_en2 = EN0; else m_en2 = EN1; };
	//enum test1<T>::MyEnum m_en2;
	enum test2::MyEnum m_en2;
int main ()
	test1<int> t1(1);
	test2<int> t2(1,0);

	If you typedef the enum type, everything works fine.
	Proper fix: gcc should handle it, I believe  ...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]