<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 - Clang fails to compile code that uses std::apply on a member variable from a __restrict member function"
   href="https://bugs.llvm.org/show_bug.cgi?id=43066">43066</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to compile code that uses std::apply on a member variable from a __restrict member function
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>mike.k@digitalcarbide.com
          </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>The following code fails to compile under Clang with '-std=c++2a' and
'-std=c++17':

#include <tuple>

struct foo {
    const std::tuple<int> v_;
    constexpr foo (int v) : v_(v) {}

    bool operator == (int value) const __restrict {
        return std::apply([](auto) {return true;}, v_);
    }
};

bool test (int v) {
    return foo{0} == v;
}

If the '__restrict' is removed from the 'operator ==', it compiles.

This code successfully compiles under GCC and MSVC:

<a href="https://godbolt.org/z/S8bGiA">https://godbolt.org/z/S8bGiA</a>

The core errors appear to be:

tuple:1271:44: error: implicit instantiation of undefined template
'std::tuple_size<__restrict std::tuple<int> >'
    inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;

tuple:1686:44: error: non-type template argument is not a constant expression
      using _Indices = make_index_sequence<tuple_size_v<decay_t<_Tuple>>>;

tuple:1687:14: error: no matching function for call to '__apply_impl'
      return std::__apply_impl(std::forward<_Fn>(__f),</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>