https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61488
Bug ID: 61488 Summary: Regression in template argument substitution in 4.9+ Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: roland at digitalvampire dot org The following code compiles fine with gcc 4.8 (and clang 3.4 for giggles). With gcc 4.9 I get the error shown; Debian's gcc-snapshot version of 4.10 behaves the same way. The non-template member function fix() is accepted by all compilers, but 4.9 rejects the template member function repair(). I don't know of any C++ language reason why the body of repair() should be treated differently. ~$ cat a.cpp struct A { typedef int (A::*cont_func)(); template <A::cont_func> void wait(int); int notify(); void fix() { wait<&A::notify>(0); } // OK template <int> void repair() { wait<&A::notify>(0); } }; ~$ for CC in gcc-4.8 clang gcc-4.9; do echo "=== $CC ("`$CC --version`")" ===; $CC -Wall -Werror -c a.cpp && echo SUCCESS; echo; done ; gcc-4.9 -v -c a.cpp === gcc-4.8 (gcc-4.8 (Debian 4.8.3-2) 4.8.3 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.) === SUCCESS === clang (Debian clang version 3.4.1-4 (tags/RELEASE_34/dot1-final) (based on LLVM 3.4.1) Target: x86_64-pc-linux-gnu Thread model: posix) === SUCCESS === gcc-4.9 (gcc-4.9 (Debian 4.9.0-5) 4.9.0 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.) === a.cpp: In member function ‘void A::repair()’: a.cpp:7:58: error: no matching function for call to ‘A::wait(int)’ template <int> void repair() { wait<&A::notify>(0); } ^ a.cpp:7:58: note: candidate is: a.cpp:3:38: note: template<int (A::* <anonymous>)()> void A::wait(int) template <A::cont_func> void wait(int); ^ a.cpp:3:38: note: template argument deduction/substitution failed: a.cpp:7:58: error: ‘&((A*)this)->*A::notify’ is not a valid template argument for type ‘int (A::*)()’ template <int> void repair() { wait<&A::notify>(0); } ^ a.cpp:7:58: error: it must be a pointer-to-member of the form ‘&X::Y’ a.cpp:7:58: error: could not convert template argument ‘&((A*)this)->*A::notify’ to ‘int (A::*)()’ Using built-in specs. COLLECT_GCC=gcc-4.9 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.0-5' --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-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-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 --with-arch-32=i586 --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.0 (Debian 4.9.0-5) COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE a.cpp -quiet -dumpbase a.cpp -mtune=generic -march=x86-64 -auxbase a -version -o /tmp/ccBdykTy.s GNU C++ (Debian 4.9.0-5) version 4.9.0 (x86_64-linux-gnu) compiled by GNU C version 4.9.0, GMP version 6.0.0, MPFR version 3.1.2-p3, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.9" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.9 /usr/include/x86_64-linux-gnu/c++/4.9 /usr/include/c++/4.9/backward /usr/lib/gcc/x86_64-linux-gnu/4.9/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++ (Debian 4.9.0-5) version 4.9.0 (x86_64-linux-gnu) compiled by GNU C version 4.9.0, GMP version 6.0.0, 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: b8ef2963d5911ef424cca776623bf2bd a.cpp: In member function ‘void A::repair()’: a.cpp:7:58: error: no matching function for call to ‘A::wait(int)’ template <int> void repair() { wait<&A::notify>(0); } ^ a.cpp:7:58: note: candidate is: a.cpp:3:38: note: template<int (A::* <anonymous>)()> void A::wait(int) template <A::cont_func> void wait(int); ^ a.cpp:3:38: note: template argument deduction/substitution failed: a.cpp:7:58: error: ‘&((A*)this)->*A::notify’ is not a valid template argument for type ‘int (A::*)()’ template <int> void repair() { wait<&A::notify>(0); } ^ a.cpp:7:58: error: it must be a pointer-to-member of the form ‘&X::Y’ a.cpp:7:58: error: could not convert template argument ‘&((A*)this)->*A::notify’ to ‘int (A::*)()’