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: unassignedclangb...@nondot.org
          Reporter: akond...@kcg.com
                CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to