This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
template friend error in 19980502
- To: egcs-bugs at cygnus dot com
- Subject: template friend error in 19980502
- From: "Hugh W. Holbrook" <holbrook at dsg dot stanford dot edu>
- Date: Fri, 8 May 1998 02:49:26 -0700
This worked in 1.0.2 but doesn't in 19980502. Apologies if this is a
duplicate.
Thanks for all of your great work. Egcs is a great tool.
/*
This program produces the following error when compiled with 19980502
$ c++ -c test.cxx
test.cxx:17: redefinition of default argument for `class Hash'
$ c++ -v
Reading specs from /usr/egcs/19980502/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.26/specs
gcc version egcs-2.91.26 19980502 (gcc2 ss-980401 experimental)
The friend declaration appears to be the culprit.
Removing it makes the problem disappear.
$ c++ -c test.cxx -DMAKE_IT_WORK
$
This compiles without error on 1.0.2.
*/
template < class Key >
struct H {
static int hash( Key k ) {
return (int) k;
}
};
template < class Key, class Hash = H<Key> >
class HashMap {
public:
class I {
public:
#ifndef MAKE_IT_WORK
friend class HashMap< Key, Hash >;
#endif
I( Key ) { }
};
I find( Key ) const { return I(0); }
};
void
foo( HashMap< int > * m ) {
m->find( 0 );
}