[LLVMbugs] [Bug 24058] New: Suspicious warning on non-deducible parameter pack

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 7 16:06:00 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: kaballo86 at hotmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150707/fd9639af/attachment.html>


More information about the llvm-bugs mailing list