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

            Bug ID: 24058
           Summary: Suspicious warning on non-deducible parameter pack
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The following snippet generates a suspicious looking warning:

    #include <cstddef>
    #include <tuple>
    #include <utility>

    template <typename ...Ts>
    struct pack {};

    template <typename LowIs, typename ...Ts>
    struct _split;

    template <std::size_t ...LowIs, typename ...Ts>
    struct _split<std::index_sequence<LowIs...>, Ts...> {
        using left = pack<
            typename std::tuple_element<LowIs, std::tuple<Ts...>>::type...>;

        template <typename Is>
        struct _right;

        template <std::size_t ...HighIs>
        struct _right<std::index_sequence<LowIs..., HighIs...>> {
            using type = pack<
                typename std::tuple_element<HighIs,
std::tuple<Ts...>>::type...>;
        };

        using right = typename
_right<std::make_index_sequence<sizeof...(Ts)>>::type;
    };

    template <typename ...Ts>
    struct split
      : _split<std::make_index_sequence<sizeof...(Ts)/2>, Ts...>
    {};

    int main() {
      split<int, float, double, bool>::left l = pack<int, float>{};
      split<int, float, double, bool>::right r = pack<double, bool>{};
      (void)l; (void)r;
    }

The warning is:

    prog.cc:20:12: warning: class template partial specialization contains a
template parameter that cannot be deduced; this partial specialization will
never be used
        struct _right<std::index_sequence<LowIs..., HighIs...>> {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    prog.cc:19:30: note: non-deducible template parameter 'HighIs'
        template <std::size_t ...HighIs>

Regardless of it compilation succeeds, so the parameter is in fact being
deduced and the specialization used. From a cursory looking at the standard,
[temp.deduct.type]/9 seems to suggest the warning is correct and the snippet
should fail to compile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to