This is the mail archive of the gcc-bugs@gcc.gnu.org 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
>Closed-Date:
>Last-Modified:
>Originator:     Kurt Garloff
>Release:        3.0.1 20010701 (prerelease)
>Organization:
SuSE GmbH Nuernberg
>Environment:
System: Linux pckurt.casa-etp.nl 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
glibc-2.1.3
>Description:
	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 
   lookup)
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.
>How-To-Repeat:
	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 <kurt@garloff.de>, 2001-06-27, (c) GNU GPL
 */

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


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

>Fix:
	If you typedef the enum type, everything works fine.
	Proper fix: gcc should handle it, I believe  ...
>Release-Note:
>Audit-Trail:
>Unformatted:


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