[llvm-bugs] [Bug 51710] New: A invalid partial specialization is accepted

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 1 20:01:26 PDT 2021


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

            Bug ID: 51710
           Summary: A invalid partial specialization is accepted
           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<typename T, T ptr>
struct A{
    static const int c = 0;
};

template<class T, T** ptr>
struct A<T*,ptr>{. 
    static const int v = 0;
};

As per [temp.spec.partial.general] p9
> Within the argument list of a partial specialization, the following restrictions apply:

>> - The partial specialization shall be more specialized than the primary template ([temp.spec.partial.order]).

`A<T*,ptr>` is not more specialized than the primary template, synthesized a
unique type for the template parameter in partial specialization, A<UniqueT*,
PTR>(where PTR has type UniqueT**) compare with A<T, ptr>

UniqueT* / T  => deduce T with UniqueT*
PTR / ptr     => deduce T with UniqueT**

as per [temp.deduct.partial] p8 and [temp.deduct.type] p2, the partial
specialization is not more specialized than the primary template.

-- 
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/b40ff4eb/attachment.html>


More information about the llvm-bugs mailing list