[llvm-bugs] [Bug 47372] New: lambda static invoker does not inherit calling convention attribute from operator()

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 31 16:06:38 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47372

            Bug ID: 47372
           Summary: lambda static invoker does not inherit calling
                    convention attribute from operator()
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                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

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;

https://godbolt.org/z/ss68Y6

... 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 *.)

-- 
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/20200831/d89f6caa/attachment.html>


More information about the llvm-bugs mailing list