https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64514
Bug ID: 64514 Summary: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: freddie_chopin at op dot pl The test code below works perfectly fine with GCC 4.8 (and 4.7): --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- #include <type_traits> template<typename T, T &object, typename... Args> struct Functor { template<float (T::*function)(Args...), Args... args> struct Inner { float operator()() const { return (object.*function)(args...); } }; }; class Object { public: float someFunction() { return {}; } float someFunctionWithArgument(int) { return {}; } }; Object object; Functor<Object, object>::Inner<&Object::someFunction> functor1; Functor<Object, object, int>::Inner<&Object::someFunctionWithArgument, 1> functor2; int main() { } --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- However with GCC 4.9 it fails with a rather unhelpful message at the point of instantiation of functor1: --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- $ g++ -std=c++11 test.cpp test.cpp: In instantiation of ‘struct Functor<Object, (* & object)>’: test.cpp:33:24: required from here test.cpp:7:9: error: wrong number of template arguments (2, should be 1) struct Inner ^ test.cpp:7:9: error: provided for ‘template<class T, T& object, class ... Args> template<float (T::* function)(Args ...), Args ...args> struct Functor<T, object, Args>::Inner’ test.cpp:7:9: error: wrong number of template arguments (2, should be 1) test.cpp:7:9: error: provided for ‘template<class T, T& object, class ... Args> template<float (T::* function)(Args ...), Args ...args> struct Functor<T, object, Args>::Inner’ test.cpp:33:26: error: ‘Inner’ in ‘struct Functor<Object, (* & object)>’ does not name a template type Functor<Object, object>::Inner<&Object::someFunction> functor1; ^ --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- If I comment the line with functor1 instantiation, everything else (functor2) works fine. At the stackoverflow question I asked ( http://stackoverflow.com/questions/27802404/error-in-template-instantiation-in-gcc-4-9-works-fine-in-gcc-4-8?noredirect=1#comment44015634_27802404 ) it was reported that clang 3.5 and Visual Studio 2015 Preview accept this code, while intel 14 errors out (with an unreported message) and solaris studio 12.4 crashes. Is there something wrong with this code (which was working for me for over 2 years with older versions) or maybe this is a regression?