<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Possible inconsistency with parameter packs in both deductible and non-deductible contexts"
   href="https://bugs.llvm.org/show_bug.cgi?id=44291">44291</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Possible inconsistency with parameter packs in both deductible and non-deductible contexts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pierre.landrock@web.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 (14.8.2.5),
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
consider

"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?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>