[llvm-bugs] [Bug 49637] New: clang accepts "this" reference in default argument of lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 18 18:09:57 PDT 2021


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

            Bug ID: 49637
           Summary: clang accepts "this" reference in default argument of
                    lambda
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: efriedma at quicinc.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Testcase:

struct A {
    void f();
    static int g(A**);
    int g(A*) const;
};
void A::f() {
    auto z = [](auto a, int r = g(decltype(a)(0))) {};
    z((A*)0);
}


gcc gives the following error:

<source>: In lambda function:
<source>:7:34: error: cannot call member function 'int A::g(A*) const' without
object
    7 |     auto z = [](auto a, int r = g(decltype(a)(0))) {};
      |                                 ~^~~~~~~~~~~~~~~~
<source>:8:12: note:   when instantiating default argument for call to
'A::f()::<lambda(auto:1, int)> [with auto:1 = A*]'
    8 |     z((A*)0);
      |            ^

-- 
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/20210319/b52d2f93/attachment.html>


More information about the llvm-bugs mailing list