This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40127] Fails to identify template function with default args


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]