[llvm-bugs] [Bug 31094] New: template parameter not deducible in partial specialization of template inside template

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 21 08:01:09 PST 2016


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

            Bug ID: 31094
           Summary: template parameter not deducible in partial
                    specialization of template inside template
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: akondrat at kcg.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The code below worked on clang 3.6, but warns on 3.8 and 3.9:

    template <typename T>
    struct outer
    {
        template <typename U>
        struct inner
        {

        };
    };


    template <typename T>
    struct is_inner_for
    {
        template <typename Whatever>
        struct predicate
        {
            static constexpr bool value = false;
        };

        template <typename U>
        struct predicate<typename outer<T>::template inner<U>>
        {
            static constexpr bool value = true;
        };
    };

    static_assert(
        is_inner_for<int>::template predicate<
            outer<int>::inner<double>
        >::value,
        "Yay!"
    );

Here is the warning:

    <source>:23:12: warning: class template partial specialization contains a
template parameter that cannot be deduced; this partial specialization will
never be used
    struct predicate<typename outer<T>::template inner<U>>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <source>:22:24: note: non-deducible template parameter 'U'
    template <typename U>
    ^
    1 warning generated.

Even though clang warns about the partial specialization not being used, the
code compiles fine and that specialization is in fact used.

GCC 6 bug that resulted in the same type of error:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70141

Godbolt output: https://godbolt.org/g/pqJcQu

Stack overflow question:
http://stackoverflow.com/questions/35875829/template-parameters-not-deducible-in-partial-specialization-in-gcc6-for-a-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/20161121/e3c1e228/attachment.html>


More information about the llvm-bugs mailing list