http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60245
Bug ID: 60245 Summary: Template static function not accepted as constexpr parameter Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: florent.hivert at lri dot fr GCC is not able to compile the following code #include <array> using Ar = std::array<unsigned long, 10>; template<typename T> constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); } static constexpr Ar id(const Ar& line) { return line; } static constexpr Ar ar1 = {{1}}; static constexpr Ar results1 = Apply<Ar>(ar1, &id); It complains that bug4.cpp:10:50: in constexpr expansion of ‘Apply<std::array<long unsigned int, 10ul> >((* & ar1), id)’ bug4.cpp:6:63: error: expression ‘id’ does not designate a constexpr function constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); } This seems to be a problem with template substitution since manually specializing the template makes the error vanish: #include <array> using Ar = std::array<unsigned long, 10>; template<typename T> constexpr T Apply(const T& in, T (*f)(const T&)) { return f(in); } // manual specialization: template<> constexpr Ar Apply<Ar>(const Ar& in, Ar (*f)(const Ar&)) { return f(in); } static constexpr Ar id(const Ar& line) { return line; } static constexpr Ar ar1 = {{1}}; static constexpr Ar results1 = Apply<Ar>(ar1, &id); System informations: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --program-suffix=-4.8 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux Thread model: posix gcc version 4.8.1 20130909 [gcc-4_8-branch revision 202388] (SUSE Linux)