[Bug c++/43506] New: name lookup fails in function template
aa.cpp: template void f(int x, T t) { f(t); } void f(int); void h() { f(1,2); } when compiled with g++ aa.cpp -c, it shows: aa.cpp: In function 'void f(int, T) [with T = int]': aa.cpp:10: instantiated from here aa.cpp:3: error: no matching function for call to 'f(int&)' once the template instantiated from aa.cpp:10 the function void f(int f) should has already been declared -- Summary: name lookup fails in function template Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yao_yin at 163 dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43506
[Bug c++/43507] New: name lookup fails in function template
aa.cpp: template void f(int x, T t) { f(t); } void f(int); void h() { f(1,2); } when compiled with g++ aa.cpp -c, it shows: aa.cpp: In function 'void f(int, T) [with T = int]': aa.cpp:10: instantiated from here aa.cpp:3: error: no matching function for call to 'f(int&)' once the template instantiated from aa.cpp:10 the function void f(int f) should has already been declared -- Summary: name lookup fails in function template Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yao_yin at 163 dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43507
[Bug c++/43506] name lookup fails in function template
--- Comment #3 from yao_yin at 163 dot com 2010-03-24 10:56 --- (In reply to comment #1) > That's not how it works. but code followed works , class X; template void f(int x, T t) { f(t); } void f(X *k); void h() { X *a; f(1,a); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43506
[Bug c++/43506] name lookup fails in function template
--- Comment #6 from yao_yin at 163 dot com 2010-03-25 02:11 --- (In reply to comment #5) > Close as a dup of bug 29131. > Comment #3 is valid as the associated namespace for X is the global > namespace. > But with fundamental types there is currently no associated namespace so the > functions are not found. Now there is a defect report against the C++ > standard > which asks if this was done that way; that is what PR 29131 references and is > suspended until the C++ standards committee decides what should happen. > *** This bug has been marked as a duplicate of 29131 *** Sorry, I gave a wrong example.. In fact, the code in PR 29131: template int t(T i) { return f (i); // OK, with g++ 4.4.3 } int f (int i) { return i; } int main() { return t(1); } can be compiled with g++ 4.4.3 but the following code cannot: template int f(int k, T i) { return f(i); // error: f not visible here } int f (int i) // overload { return i; } int main() { return f(1, 2); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43506
[Bug c++/43506] name lookup fails in function template
--- Comment #7 from yao_yin at 163 dot com 2010-03-29 01:56 --- Sorry, I gave a wrong example.. In fact, the code in PR 29131: template int t(T i) { return f (i); // OK, with g++ 4.4.3 } int f (int i) { return i; } int main() { return t(1); } can be compiled with g++ 4.4.3 but the following code cannot: template int f(int k, T i) { return f(i); // error: f not visible here } int f (int i) // overload { return i; } int main() { return f(1, 2); } -- yao_yin at 163 dot com changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|DUPLICATE | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43506