https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69205
Bug ID: 69205 Summary: Place a variadic temlate in front of function parameter when it is knoen Product: gcc Version: c++-concepts Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mohsen.tamiz at gmail dot com Target Milestone: --- Created attachment 37293 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37293&action=edit Preprocessed file of my example. This is the program that gives me a compile error: #include <functional> using namespace std; template<typename ActionType, typename... Cols> void print_action(function<ActionType*(Cols..., ActionType)> action_factory) { } int main(int argc, char *argv[]) { print_action<string, uint8_t>(function<string*(uint8_t, string)>()); return 0; } The problem is that the compiler could not understand the place of the variadic parameter. Some hints advised that the variadic parameters of action_factory must be the last parameter because It is greedy and consumes all paramteres, but I specified the Cols... explicitly in template parameter and compiler must know that what ActionType and Cols... are and there must no deduction or parameter guessing remained for compiler. This is the output of command g++ -v -std=c++11 foo.cc -Wall -Wextra -save-temps. And I attached *.i file to the bug, although, this is a minimal testcase and it needs just <functional> header. Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,\ fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with\ -gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-uni\ que-object --disable-libmudflap --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-gc\ j-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-direct\ ory=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,mx\ 32 --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.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-Wall' '-Wextra' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE foo.cc -mtune=generic -march=x86-64 -std=c++11 -Wall -Wextra -fpch-preprocess\ -fstack-protector -Wformat-security -o foo.ii ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.8 /usr/include/x86_64-linux-gnu/c++/4.8 /usr/include/c++/4.8/backward /usr/lib/gcc/x86_64-linux-gnu/4.8/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-Wall' '-Wextra' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -fpreprocessed foo.ii -quiet -dumpbase foo.cc -mtune=generic -march=x86-64 -auxbase foo -Wall -Wextra -std=c++11 -version -fstack-pro\ tector -Wformat-security -o foo.s GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu) compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu) compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 9cb21c615435621dce26fe5e793192fd foo.cc: In function ‘int main(int, char**)’: foo.cc:12:69: error: no matching function for call to ‘print_action(std::function<std::basic_string<char>*(unsigned char, std::basic_string<char>)>)’ print_action<string, uint8_t>(function<string*(uint8_t, string)>()); ^ foo.cc:12:69: note: candidate is: foo.cc:6:6: note: template<class ActionType, class ... Cols> void print_action(std::function<ActionType*(Cols ..., ActionType)>) void print_action(function<ActionType*(Cols..., ActionType)> action_factory) ^ foo.cc:6:6: note: template argument deduction/substitution failed: foo.cc:12:69: note: mismatched types ‘std::basic_string<char>’ and ‘unsigned char’ print_action<string, uint8_t>(function<string*(uint8_t, string)>()); ^ foo.cc:12:69: note: ‘std::function<std::basic_string<char>*(unsigned char, std::basic_string<char>)>’ is not derived from ‘std::function<std::basic_string<char>*(Cols ..., st\ d::basic_string<char>)>’ foo.cc: At global scope: foo.cc:10:5: warning: unused parameter ‘argc’ [-Wunused-parameter] int main(int argc, char *argv[]) ^ foo.cc:10:5: warning: unused parameter ‘argv’ [-Wunused-parameter]