https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81232
Bug ID: 81232 Summary: compiler crashes for template function overload Product: gcc Version: 6.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: manish.baphna at citi dot com Target Milestone: --- Created attachment 41636 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41636&action=edit diagnostic output from compiler I am trying to use template function overloads and in a specific case, I was expecting to deploy 'best match' overload but that somehow is not happening. Template type deduction there is not matching 'best match' and compiler is crashing(gcc6.1). Explicitly specifying types is helping here. Check main for both versions of my usage. At this moment I am not sure if it's issue with gcc or with my assumptions. Here is code #include <iostream> #include <type_traits> using namespace std; template <int N> using int_ = integral_constant<int,N>; struct Meta { template<int N, typename T> static constexpr T ipow(T x) { return ipow<N, T>(x, int_<(N < 0) ? -1 : N>()); } template<int N, typename T> static constexpr T ipow(T x, int_<-1>) { return static_cast<T>(1) / ipow<-N>(x, int_<-N>()); } template<int N, typename T> static constexpr T ipow(T x, int_<N>) { return x * ipow<N-1>(x, int_<N-1>()); } template<int N, typename T> static constexpr T ipow(T x, int_<0>) { return 1; } }; int main(){ Meta m1; cout << m1.ipow<-1, int>(2, int_<-1>()) << endl; // This works fine cout << m1.ipow(2, int_<-1>()) << endl; // This crashes compiler }