[llvm-bugs] [Bug 41037] New: Incorrect error message when assigning to a const member in a mutable lambda
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 11 14:08:47 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41037
Bug ID: 41037
Summary: Incorrect error message when assigning to a const
member in a mutable lambda
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: metaprogrammingtheworld at gmail.com
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
When capturing a reference-to-const by value in a mutable lambda, an incorrect
error message is produced if attempting to assign to the captured object. The
current error message claims that the variable is being assigned-to in a
non-mutable lambda when in actuality the lambda *is* mutable, but the type of
the captured object is const (so the object is still const from within the body
of the mutable lambda's function call operator).
Example:
//////////
int main() {
int const& ref = 0;
// error: cannot assign to a variable captured by copy in a non-mutable
lambda
[ref]() mutable { ref = 4; }();
}
//////////
This is similar but different from bug 24016.
--
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/20190311/02aea786/attachment-0001.html>
More information about the llvm-bugs
mailing list