This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15674] New: template argument binding differs between member and static fumctions
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 May 2004 07:15:25 -0000
- Subject: [Bug c++/15674] New: template argument binding differs between member and static fumctions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#include <iostream>
int a[5];
int* p;
template<typename T>
class Foo {
public:
void S(T*) { std::cout << "found ref" << std::endl; }
template<size_t n>
void S(T(&a)[n]) { std::cout << "found array" << std::endl; }
};
template<typename T>
void S(T*) { std::cout << "found ref" << std::endl; }
template<typename T, size_t n>
void S(T(&a)[n]) { std::cout << "found array" << std::endl; }
int main() {
Foo<int> s;
s.S(a);
s.S(p);
S(a);
S(p);
return 0;
}
When run, this produces:
~/ootbc/common/test/src$ a.out
found ref
found ref
found array
found ref
That is, the two calls to the member S both bind to the T* template, but for the global functions with identical signature one binds to each overload.
Ivan
--
Summary: template argument binding differs between member and
static fumctions
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15674