[llvm-bugs] [Bug 51709] New: The explicitly specialized primary template class shall supress consideration of other partial specialization

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 1 19:50:40 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51709

            Bug ID: 51709
           Summary: The explicitly specialized primary template class
                    shall supress consideration of other partial
                    specialization
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xmh970252187 at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

template<class T> struct A {
  template<class T2> struct B {
     static const int value = 1;
  };                               // #1
  template<class T2> struct B<T2*> {
     static const int value = 2;
  };                          // #2
};

template<> template<class T2> struct A<short>::B {
    static const int value = 3;
};            // #3
int main(){
   std::cout<< A<short>::B<int*>::value;  // shall be 3
}

Clang give `2`, as per [temp.spec.partial.member] p2.   

> If a member template of a class template is partially specialized, the member template partial specializations are member templates of the enclosing class template; if the enclosing class template is instantiated ([temp.inst], [temp.explicit]), a declaration for every member template partial specialization is also instantiated as part of creating the members of the class template specialization. If the primary member template is explicitly specialized for a given (implicit) specialization of the enclosing class template, the partial specializations of the member template are ignored for this specialization of the enclosing class template. If a partial specialization of the member template is explicitly specialized for a given (implicit) specialization of the enclosing class template, the primary member template and its other partial specializations are still considered for this specialization of the enclosing class template.  

We explicitly specialized the primary template class `B` for enclosing class
template specialization A<short>, hence the other partial specialization shall
not be considered anymore.

-- 
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/20210902/45e7ab7b/attachment.html>


More information about the llvm-bugs mailing list