[Bug c++/18681] New: template friend declaration not recognized
wolfgang dot roehrl at de dot gi-de dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 26 13:52:00 GMT 2004
Dear all,
I would like to post a fault report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor.
Used invokation line for the GNU C++ compiler:
ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
-fmerge-templates -mmultiple -mno-string -mstrict-align -O3
-fno-exceptions -fno-rtti -fno-builtin-printf
-I<different include paths>
-D<differen #define's>
K.CPP -oK.O
// example program
template <typename> class C1;
template <typename> class C2;
template <typename T_>
class C2<T_*>
{
typedef T_* T_PAR_TYPE; <---- k.CPP, line 7
friend class C1<T_*>; <---- class C1<int (*)[20]> is a friend
};
template <typename T_>
class C1
{
//public: <---- k.CPP, line 14
typedef typename C2<T_>::T_PAR_TYPE T_PAR;
struct S1
{
T_PAR par; <---- k.CPP, line 18
};
static void fx (S1&);
public:
void f (T_PAR ptr);
};
template <typename T_>
void C1<T_>::f (T_PAR ptr_)
{
S1 s1; <---- k.CPP, line 31
fx (s1);
}
typedef int T_MEM[20];
void f (T_MEM* p1)
{
C1<T_MEM*> c1;
c1.f (p1); <---- k.CPP, line 45
}
The compiler gives the following error messages:
k.CPP: In instantiation of `C1<int (*)[20]>::S1':
k.CPP:31: instantiated from `void C1<<anonymous template type parameter> >::f
(typename C2<<anonymous template type parameter> >::T_PAR_TYPE) [with T_ = int
(*)[20]]'
k.CPP:45: instantiated from here
k.CPP:7: error: `typedef int (*C2<int (*)[20]>::T_PAR_TYPE)[20]' is private
k.CPP:18: error: within this context
The error messages remain the same if line 14 is un-commented. This seems OK
since the access specification of C1<>::T_PAR should not affect C1<>::S1. The
compiler translates only without complaints if C2<>::T_PAR_TYPE is made public.
With kind regards
W. Roehrl
--
Summary: template friend declaration not recognized
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wolfgang dot roehrl at de dot gi-de dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.5.1
GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18681
More information about the Gcc-bugs
mailing list