http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57520
Bug ID: 57520 Summary: alias template substitution/deduction failure Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stephen.pope at predict dot com gcc 4.8.1 (as well as 4.8.0 and 4.7.2) appears to fail to correctly substitute the alias's template-id for an alias template instantiation when reference or by pointer types are involved. I was able to whittle a messy real-world problem down to a minor variation on the non-normative example provided in the C++ 11 standard section temp.alias (14.5.7/2): #include <vector> using namespace std; template <class T> using Vec = vector<T, allocator<T>>; template <template <class> class TT> void f1(TT<int> v); template <template <class> class TT> void f2(TT<int>& v); template <template <class> class TT> void f3(TT<int>* v); template <template <class, class> class TT> void g1(TT<int, allocator<int>> v); template <template <class, class> class TT> void g2(TT<int, allocator<int>>& v); template <template <class, class> class TT> void g3(TT<int, allocator<int>>* v); void foo() { Vec<int> v; f1(v); // gcc and clang both correctly yield no matching function error g1(v); f2(v); // clang yields a no matching function error g2(v); // gcc yields a no matching function error f3(&v); // clang yields a no matching function error g3(&v); // gcc yields a no matching function error } (compile with -std=c++11) As noted above, clang 3.3 (recent pull from svn) and gcc (4.7.2, 4.8.0, and 4.8.1) agree on the handling of f1/g1 in conformance with the standard, but differ on the handling of f2/g2 and f3/g3 (to be clear, all tested versions of gcc incorrectly accept the call to f2() and f3() and error on the call to g2() and g3()). All indications, both in this example and in my real problem, are that gcc is not correctly converting the type of the instantiation of the alias template (e.g. Vec<int>) to the aliased type (e.g. vector<int, allocator<int>>) prior to trying to deduce the template parameter for the instantiations of f2, f3, g2, and g3. Here is the full error output of gcc-4.8.1: % gcc-4.8.1/bin/g++ -Wall -Wextra -std=c++11 temp.cpp temp.cpp: In function 'void foo()': temp.cpp:30:8: error: no matching function for call to 'f1(Vec<int>&)' f1(v); // gcc and clang both correctly yield no matching function error ^ temp.cpp:30:8: note: candidate is: temp.cpp:9:6: note: template<template<class> class TT> void f1(TT<int>) void f1(TT<int> v); ^ temp.cpp:9:6: note: template argument deduction/substitution failed: temp.cpp:30:8: error: wrong number of template arguments (2, should be 1) f1(v); // gcc and clang both correctly yield no matching function error ^ temp.cpp:8:34: error: provided for 'template<class> class TT' template <template <class> class TT> ^ temp.cpp:34:8: error: no matching function for call to 'g2(Vec<int>&)' g2(v); // gcc yields a no matching function error ^ temp.cpp:34:8: note: candidate is: temp.cpp:21:6: note: template<template<class, class> class TT> void g2(TT<int, std::allocator<int> >&) void g2(TT<int, allocator<int>>& v); ^ temp.cpp:21:6: note: template argument deduction/substitution failed: temp.cpp:34:8: error: wrong number of template arguments (1, should be 2) g2(v); // gcc yields a no matching function error ^ temp.cpp:20:41: error: provided for 'template<class, class> class TT' template <template <class, class> class TT> ^ temp.cpp:37:9: error: no matching function for call to 'g3(Vec<int>*)' g3(&v); // gcc yields a no matching function error ^ temp.cpp:37:9: note: candidate is: temp.cpp:24:6: note: template<template<class, class> class TT> void g3(TT<int, std::allocator<int> >*) void g3(TT<int, allocator<int>>* v); ^ temp.cpp:24:6: note: template argument deduction/substitution failed: temp.cpp:37:9: error: wrong number of template arguments (1, should be 2) g3(&v); // gcc yields a no matching function error ^ temp.cpp:23:41: error: provided for 'template<class, class> class TT' template <template <class, class> class TT> ^