[LLVMbugs] [Bug 17294] New: clang does not find partial specializations of a member template of a class template that are declared after the class template is instantiated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 19 13:50:24 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17294

            Bug ID: 17294
           Summary: clang does not find partial specializations of a
                    member template of a class template that are declared
                    after the class template is instantiated
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Case 1, member class templates:

template<typename A> struct X { template<typename B> struct Y {}; };
X<int> x;
template<typename A> template<typename B> struct X<A>::Y<B*> { int n; };
int k = X<int>::Y<int*>().n;

We reject this, because line 2 triggers the instantiation of X<int>, and we
don't find partial specializations for the template that are declared after
that instantiation.

Case 2, static data member templates:

template<typename A> struct X { template<typename B> static const int n; };
X<int> x;
template<typename A> template<typename B> const int X<A>::n<B*> = 1;
int arr[X<int>::n<int*>];

We reject this for the same reason.

It's not *entirely* obvious that we're wrong here, because 14.5.5.3/2 says:

"if the enclosing class template is instantiated (14.7.1, 14.7.2), a
declaration for every member template partial specialization is also
instantiated as part of creating the members of the class template
specialization."

But g++ and EDG at least accept the member class templates case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130919/15694cc0/attachment.html>


More information about the llvm-bugs mailing list