internal compiler error with friend/templates/namespace

Gabriel Dos Reis gdr@codesourcery.com
Tue Apr 18 09:49:00 GMT 2000


Dimitri PAPADOPOULOS-ORFANOS <papadopo@shfj.cea.fr> writes:

| Hi,
| 
| This is GCC 2.95.2 19991024 and I get an internal compiler error
| while trying to compile this:
| 
| 	namespace me {
| 
| 	template <typename T>
| 	class rc_ptr {
| 		template <typename U> friend class rc_ptr;
| 	};
| 	
| 	}
| 
| I won't swear the code is correct. 

The code is correct.

| ... I am trying to tell the compiler
| that rc_ptr<U>  for any type U should be a friend of rc_ptr<T>. This
| is probably not possible I guess...

That is possible, the above is the way to go.

| $ g++ -v
| Reading specs from 
| /usr/local/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
| gcc version 2.95.2 19991024 (release)
| $ cat foo.cc
| namespace me {
| 
| template <typename T>
| class rc_ptr {
| 	template <typename U> friend class rc_ptr;
| };
| 
| }
| $ g++ -c foo.cc
| foo.cc:5: Internal compiler error.
| foo.cc:5: Please submit a full bug report.
| foo.cc:5: See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for 
| instructions.
| $ 


This problem seems to be caused by the conjunction use of namespace.
I was able to get g++-2.95.2 grok it without problem when rc_ptr is
defined iin the global namespace.

Current CVS accept your original code without problem, so I guess the
problem was fixed.

-- Gaby
CodeSourcery, LLC                             http://www.codesourcery.com


More information about the Gcc-bugs mailing list