I have a strange compile error with GCC 5.1.0 (tdm64-1) compiling the following code
template <class T>
struct test {
    template <class X>
    bool func();
};
template <class X, class Y>
bool testfunc(X x, Y y)
{
  test<Y>  s;
  if (s.func<X>())    // <-- parse error here
      return false;
}
void func2()
{
 testfunc( double(), long() );
}
The error is
testX.cpp: In function 'bool testfunc(X, Y)': 
testX.cpp:12:15: error: expected primary-expression before '>' token 
   if (s.func<X>()) 
               ^ 
testX.cpp:12:17: error: expected primary-expression before ')' token 
   if (s.func<X>()) 
Note that the error only occurs in the version when Y is a template parameter. When I remove the Y template parameter and instantiate test with a known type (e.g. test< int>), it compiles without error.
So what is wrong here?