This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40127] Fails to identify template function with default args
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 15 Jan 2012 20:01:35 +0000
- Subject: [Bug c++/40127] Fails to identify template function with default args
- Auto-submitted: auto-generated
- References: <bug-40127-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40127
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-15 20:01:35 UTC ---
This code is invalid (and other compilers agree with me). What type is going
to be chosen for T? void*, int*, any pointer type? There is no way the
compiler can deduce the type of T from the arguments.
This code is valid though:
template<typename T>
void foo(int i, void(*f)(T*) = 0, T* a = 0) {}
int main() {
foo<void>(5);
return 0;
}
AS the compiler does not need to deduce the template argument type.