https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64587
Bug ID: 64587 Summary: [C++11] Wrong number of template arguments when template template parameter is template alias. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: splinterofchaos at gmail dot com Created attachment 34439 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34439&action=edit The error-producing file. As far as I have been able to gather, and according to everyone I've asked, the following should be valid: #include <utility> template<class T> using decay = typename std::decay<T>::type; template<template<class...>class T, class...X> struct Part { template<class...Y> using type = T<X..., Y...>; }; template<template<class...>class T, template<class>class U> struct UCompose { // Not ok! template<class X, class...Y> using type = T<U<X>, Y...>; //// Ok! //template<class X> //using type = T<U<X>>; }; int main() { using IsInt = Part<std::is_same, int>; static_assert(IsInt::type<int>::value, ""); // Ok! using IsIntD = UCompose<IsInt::type, decay>; static_assert(IsIntD::type<int&>::value, ""); // Not ok. } The error is: $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.1-16ubuntu6' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.9.1 (Ubuntu 4.9.1-16ubuntu6) $ g++ tmp.cpp --std=c++11 -Wall -Wextra -save-temps tmp.cpp: In substitution of ‘template<template<class ...> class T, class ... X> template<class ... Y> using type = T<X ..., Y ...> [with Y = {typename std::decay<_Tp>::type, Y ...}; T = std::is_same; X = {int}]’: tmp.cpp:16:29: required from ‘struct UCompose<Part<std::is_same, int>::type, decay>’ tmp.cpp:27:23: required from here tmp.cpp:9:29: error: wrong number of template arguments (3, should be 2) using type = T<X..., Y...>; ^ In file included from /usr/include/c++/4.9/bits/move.h:57:0, from /usr/include/c++/4.9/bits/stl_pair.h:59, from /usr/include/c++/4.9/utility:70, from tmp.cpp:1: /usr/include/c++/4.9/type_traits:922:12: error: provided for ‘template<class, class> struct std::is_same’ struct is_same; ^ The message, "wrong number of template arguments" implies that three parameters are passed, but above it says "X = {int}" and "Y = {typename std::decay<_Tp>::type, Y ...}". The "Y ..." here should be empty; perhaps it comes from "UCompose::type", where again the "Y..." should be empty. I have tried with gcc 4.8 and get the same error message. Attached is the output from -save-temps