g++-2.95.2 bug
Martin Schweiger
martins@medphys.ucl.ac.uk
Tue Nov 7 07:00:00 GMT 2000
Problem:
--------
"rejects-legal" (I think):
Compilation of a template class fails when a member function
has the same name as a template friend function.
GCC version:
------------
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu)
compiled by GNU C version 2.95.2 19991024 (release).
System type:
------------
i686-pc-linux-gnu
Command line:
-------------
g++ test.cc
Compiler output:
----------------
test.cc: In instantiation of `foo<double>':
test.cc:26: instantiated from here
test.cc:9: invalid use of undefined type `class foo<double>'
test.cc:11: forward declaration of `class foo<double>'
Preprocessed file (test.ii):
----------------------------
# 1 "test.cc"
template<class T>
class foo;
template<class T>
void bar(foo<T>);
template<class T>
class foo {
friend void bar<>(foo<T>);
int bar (void);
};
template<class T>
void bar(foo<T>) {
int x = 1;
}
template<class T>
int foo<T>::bar (void)
{
return 1;
}
int main(void)
{
foo<double> f;
return 0;
}
GCC configure options:
----------------------
--with-gcc-version-trigger=/home/martins/gcc-2.95.2/gcc/version.c
--host=i686-pc-linux-gnu
--norecursion
Martin Schweiger, Ph.D. <martins@medphys.ucl.ac.uk>
Department of Medical Physics, UCL
Tel: +44(0)20-7679-6411 Fax: +44(0)20-7679-6269
URL: http://www.medphys.ucl.ac.uk/~martins/
More information about the Gcc-bugs
mailing list