public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3526: ICE on inherited enum
@ 2001-07-02  1:46 Kurt Garloff
  0 siblings, 0 replies; 5+ messages in thread
From: Kurt Garloff @ 2001-07-02  1:46 UTC (permalink / raw)
  To: gcc-gnats

>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:


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/3526: ICE on inherited enum
@ 2003-01-23  4:23 neroden
  0 siblings, 0 replies; 5+ messages in thread
From: neroden @ 2003-01-23  4:23 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gdr, kurt

Synopsis: ICE on inherited enum

State-Changed-From-To: open->closed
State-Changed-By: neroden
State-Changed-When: Thu Jan 23 04:23:53 2003
State-Changed-Why:
    In mainline, currently we get:
    ice.cxx: At global scope:
    ice.cxx:20: error: `typename test2<T>::MyEnum' referred to as enum
     test2<T>::test2(int, int)
    ice.cxx:17: error: `EN0' has not been declared
    ice.cxx:17: error: `EN1' has not been declared

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3526


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/3526: ICE on inherited enum
@ 2003-01-23  4:06 Giovanni Bajo
  0 siblings, 0 replies; 5+ messages in thread
From: Giovanni Bajo @ 2003-01-23  4:06 UTC (permalink / raw)
  To: gdr; +Cc: gcc-prs

The following reply was made to PR c++/3526; it has been noted by GNATS.

From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<gdr@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<kurt@garloff.de>
Cc:  
Subject: Re: c++/3526: ICE on inherited enum
Date: Thu, 23 Jan 2003 04:58:08 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=3526
 
 Comeau is right, because EN0/EN1 cannot be found within the default name
 lookup, since the base class is a template. This should be fixed by this
 patch: http://gcc.gnu.org/ml/gcc-patches/2003-01/msg01166.html
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/3526: ICE on inherited enum
@ 2003-01-02 20:53 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2003-01-02 20:53 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gdr, kurt

Synopsis: ICE on inherited enum

State-Changed-From-To: analyzed->open
State-Changed-By: neil
State-Changed-When: Thu Jan  2 12:53:48 2003
State-Changed-Why:
    3.4 gives the helpful
    
    /tmp/bug.C:31: error: `typename test2<T>::MyEnum' referred to as enum
    
    but Comeau rejects the code as follows, so maybe we're still buggy?
    
    "ComeauTest.c", line 16: error: identifier "EN0" is undefined
      	test2 (int i, int j) : test1<T>(i) {if (j==0) m_en2 = EN0; else m_en2 = EN1; };
      	                                                      ^
    
    "ComeauTest.c", line 16: error: identifier "EN1" is undefined
      	test2 (int i, int j) : test1<T>(i) {if (j==0) m_en2 = EN0; else m_en2 = EN1; };
      	                                                                        ^

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3526


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/3526: ICE on inherited enum
@ 2001-08-12  3:48 gdr
  0 siblings, 0 replies; 5+ messages in thread
From: gdr @ 2001-08-12  3:48 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gdr, kurt, nobody

Synopsis: ICE on inherited enum

Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Sun Aug 12 03:48:53 2001
Responsible-Changed-Why:
    See below.
State-Changed-From-To: open->analyzed
State-Changed-By: gdr
State-Changed-When: Sun Aug 12 03:48:53 2001
State-Changed-Why:
    Your program is ill-formed: You should be using the `typename'
    keyword as follows:
    
       typename test2<T>::MyEnum
    
    However, GCC's diagnostic is competely bogus.
    Patch in progress.
    
    -- Gaby

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3526&database=gcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-23  4:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-02  1:46 c++/3526: ICE on inherited enum Kurt Garloff
2001-08-12  3:48 gdr
2003-01-02 20:53 neil
2003-01-23  4:06 Giovanni Bajo
2003-01-23  4:23 neroden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).