[cfe-dev] clang fails to match definition of class template member function
KARTHIKVENKATESH BHAT
kv.bhat at samsung.com
Sun Sep 23 23:29:22 PDT 2012
Hi All,
We were looking into templates implementation in clang and came across an issue in template implementation of clang.
When we try to compile the following code-
template <int dim> class X {};
template <class T> struct Y {
static const unsigned int dim = 1;
template <class U> X<Y<T>::dim> f();
};
template <class T> template <class U>
X<Y<T>::dim> Y<T>::f() { return X<dim>(); }
int main()
{
Y<int>().f<int>();
}
the compilation fails with error -
error: out-of-line definition of 'f' does not match any declaration in 'Y<T>'
X<Y<T>::dim> Y<T>::f() { return X<dim>(); }
This compiles successfully in case of gcc and intel compiler.
Upon debugging we found that the return type for the definition and declaration are mismatatching resulting in this error.
We also found that in case of templates in Sema::CheckTemplateIdType function we use cannonType actually represents
TemplateSpecializationType which might be causing the issue.
Would like few inputs from community about fixing this issue.
Thanks and Regards
Karthik
More information about the cfe-dev
mailing list