<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 - lambda static invoker does not inherit calling convention attribute from operator()"
   href="https://bugs.llvm.org/show_bug.cgi?id=47372">47372</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lambda static invoker does not inherit calling convention attribute from operator()
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </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>Testcase:

auto f(int a, int b) [[gnu::cdecl]] { return a + b; }
auto g(int a, int b) [[gnu::regcall]] { return a + b; }

auto p = [](int a, int b) [[gnu::cdecl]] { return a + b; };
auto q = [](int a, int b) [[gnu::regcall]] { return a + b; };

auto x = &decltype(p)::operator();
auto y = &decltype(q)::operator();
void *z[2] = {&x, &y};

auto *static_x = +p;
auto *static_y = +q;

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

... uses regcall calling convention for g and q's operator(), but not for q's
static invoker. Indeed,

int (*static_x_regcall)(int, int) [[gnu::regcall]] = q;

... is rejected because there's no conversion function to a function pointer
with the right calling convention.

We should decide whether we want an explicit calling convention attribute on
the operator() to carry through to the conversion function. (If we fix PR38285
first, this should only affect the "default" calling convention used by (eg)
decaying a lambda to a function pointer with unary + or *.)</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>