This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: ICE with friend templates
- To: Cleveland Flowe <cflowe at bellsouth dot net>
- Subject: Re: ICE with friend templates
- From: <llewelly at 198 dot dsl dot xmission dot com>
- Date: Sun, 19 Dec 1999 20:22:48 -0700 (MST)
- cc: gcc-bugs at gcc dot gnu dot org
On Sun, 19 Dec 1999, Cleveland Flowe wrote:
> `gcc -v --save-temps -c bug.cc` produces:
>
> # 1 "bug.cc"
> template <class T> class A;
>
> template <class T>
> class D
> {
> public:
> D(void) {;}
>
> public:
> template <class X> friend A<X>;
> };
>
> class G : public D<int>
> {
> public:
> G(void) {;}
> };
>
> Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
> gcc version 2.95.2 19991024 (release)
> /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c++ -v -D__GNUC__=2
> -D__GNU
> G__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__
> -Dlinux -D__
> ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
> -Asystem(posix) -D__E
> XCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
> -Dpentiu
> mpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ bug.cc bug.ii
> GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include/g++
> /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/include
>
> /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
> /usr/include
> End of search list.
> The following default directories have been omitted from the search
> path:
> /usr/local/include
> End of omitted list.
> /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus bug.ii -quiet
> -dumpbase bug.cc -version -o bug.s
> GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled
> by GNU C
> version 2.95.2 19991024 (release).
> bug.cc: In instantiation of `D<int>':
> bug.cc:14: instantiated from here
> bug.cc:5: Internal compiler error.
> bug.cc:5: Please submit a full bug report.
> bug.cc:5: See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport>
> for instructions.
Try:
template <class T> class A;
template <class T>
class D
{
public:
D(void) {;}
public:
template <class X> friend class A;
};
class G : public D<int>
{
public:
G(void) {;}
};
For me, using gcc-2.95.2 on an i686-pc-linux-gnu (modified rh 6.1), this
compiles with no errors.
Don't take this to mean that this gcc ICE is okay; (I don't think an ICE
should *ever* be okay) I just wanted you to know that the 'correct' way
of declaring friend templates does work.