This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15707] New: unexpected redefinition error in overloaded member template functions
- From: "chris at uzdavinis dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2004 15:52:40 -0000
- Subject: [Bug c++/15707] New: unexpected redefinition error in overloaded member template functions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Valid code doesn't compile. The two Foo<T>::foo<> member definitions confuse
the compiler. (This problem exists in 3.2, 3.3, and 3.4 versions of g++)
class Foo
{
public:
template<typename U>
void foo();
template<typename U, typename V>
void foo();
};
template<typename U>
void Foo::foo() {}
template<typename U, typename V>
void Foo::foo() {}
int main()
{
Foo f;
f.foo<int>();
f.foo<int, int>();
}
$ g++ -v -save-temps test.cpp
Reading specs from /usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ./configure
--prefix=/home/coryan/HEAD/specs/BUILD//usr/local/gcc-3.4.0 --enable-threads
Thread model: posix
gcc version 3.4.0
/usr/local/gcc-3.4.0/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -E
-quiet -v -iprefix /usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/
-D_GNU_SOURCE test.cpp -mtune=pentiumpro -o test.ii
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
/usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
/usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
/usr/local/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/include
/usr/local/include
/usr/include
End of search list.
/usr/local/gcc-3.4.0/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus
-fpreprocessed test.ii -quiet -dumpbase test.cpp -mtune=pentiumpro -auxbase test
-version -o test.s
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
test.cpp:14: error: got 1 template parameters for `void Foo::foo()'
test.cpp:14: error: but 2 required
test.cpp:20: error: redefinition of `void Foo::foo()'
test.cpp:14: error: `void Foo::foo()' previously declared here
--
Summary: unexpected redefinition error in overloaded member
template functions
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris at uzdavinis dot com
CC: gcc-bugs at gcc dot gnu dot org,pbrannan at atdesk dot
com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15707