This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Fwd: g++: Internal compiler error: program cc1plus got fatal signal 11]
"Martin v. Loewis" wrote:
> > The compiler has and WILL HAVE (!?) problem with this construction.
> [...]
> > template <typename S1> friend void AAA<S1> ();
>
> No wonder the compiler has problems with this: It is illegal code.
> The compiler says
>
> a.cc:6: template-id `AAA<S1>' in declaration of primary template
>
> > ---> template <typename S1> friend class AAA<S1>; <---
> >
> > The compiler has no problem with this construction.
>
> The compiler is wrong, this is also ill-formed. gcc 2.95 says
>
> a.cc:8: partial specialization `AAA<S1>' declared `friend'
Here is a template class.
template <typename T>
class XXX
{
friend class AAA<T>;
template <typename S> friend class BBB<S>; // It will be illegal
code
};
------------ about AAA ----------
Class AAA<int> is a friend of XXX<int>.
Class AAA<char> is a friend of XXX<char>
But
AAA<char> is not a friend of XXX<int>
AAA<int> is not a friend of XXX<char>
It's OK, it is what I want.
--------------------------------
------------ about BBB-------------
I want BBB<S> (for any S) to be a friend of AAA<T> (for any T)
For example
Class BBB<int> is a friend of XXX<int>
Class BBB<char> is a friend of XXX<char>
And
Class BBB<char> is a friend of XXX<int>
Class BBB<int> is a friend of XXX<char>
Will it be impossible?
-----------------------------------
>
>
> If you remove the errors in your program, g++ accepts the code.
>
> Regards,
> Martin
Thanks in advance,
Alex