[llvm-bugs] [Bug 44291] New: Possible inconsistency with parameter packs in both deductible and non-deductible contexts

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 13 04:10:51 PST 2019


            Bug ID: 44291
           Summary: Possible inconsistency with parameter packs in both
                    deductible and non-deductible contexts
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pierre.landrock at web.de
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Code snippet:


template <typename T>
struct Identity
    using type = T;

template <typename T>
using IdentityType = typename Identity<T>::type;

template <typename... TArgs>
int extraArgAfterPack(
    int (* const func)(TArgs...),
    IdentityType<TArgs>... nonDeducibleArgs,
    int extraArg)
    return (*func)(nonDeducibleArgs...) + extraArg;

template <typename... TArgs>
int extraArgBeforePack(
    int (* const func)(TArgs...),
    int extraArg,
    IdentityType<TArgs>... nonDeducibleArgs)
    return (*func)(nonDeducibleArgs...) + extraArg;

int f(const int& i)
    return i;

int main()
    return extraArgAfterPack(&f, 22, 20);             // (1) Fails to compile 
//    return extraArgAfterPack<const int&>(&f, 22, 20); // (2) Compiles
//    return extraArgBeforePack(&f, 20, 22);            // (3) Compiles


Item (1) of the preceeding code fails to compile under clang 4.0.0 onwards (it
compiles in lower versions, however). I suppose, this has to do with:

"when a function parameter pack appears in a non-deduced context (,
the type of that parameter pack is never deduced."

In each function signature, the parameter pack appears both in a deductible and
a non-deductible context. Hence, it should be correct, that the code fails to
compile in item (1). Specifying the template parameters explicitly (as in item
(2)) gets rid of this problem, since no deduction occurs.
However, the same situation as in (1) applies to item (3) with the difference,
that the non-deductible parameter pack is now trailing. Thus, one might have to

"A trailing template parameter pack (14.5.3) not otherwise deduced will be
deduced to an empty sequence of template arguments"

The pack is still non-deductible and the first point should apply. What is the
correct behaviour here?

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

More information about the llvm-bugs mailing list