[llvm-bugs] [Bug 46102] New: Non mutable lambdas still see some non const references

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 27 08:07:46 PDT 2020


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

            Bug ID: 46102
           Summary: Non mutable lambdas still see some non const
                    references
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rafael at espindo.la
                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

Both clang and gcc agree that the following should not compile

struct foo {
    void func();
};
void zed(const foo& v) {
    [v]() mutable {
        v.func();
    }();
}

The problem being that the member corresponding to v is now const.

But the following function compiles with clang while gcc rejects it

void bar(foo& v) {
    [v]() {
        [v]() mutable {
             v.func();
        }();
    }();
}

The operator() of the outer lambda should be const, so the v in the inner
lambda should be const too, and gcc is correct in rejecting this as far as I
can tell.

-- 
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/20200527/19e2decc/attachment.html>


More information about the llvm-bugs mailing list