https://bugs.llvm.org/show_bug.cgi?id=41410
Bug ID: 41410
Summary: Misleading error message 'this' was not captured for
this lambda function
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: gabriel.aubut-luss...@outlook.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
The error message given when 'this' cannot be captured is misleading in the
sense that it points the user to the lambda that fails to capture 'this' rather
than raise questions about why it fails to do so.
The icc compiler does the best job of giving context with this error. MSVC also
displays a bit more information. Clang has the worst offender. GCC could use a
bit of improvement. Aiming for an error message that is closer to icc seems
like the ideal solution. The error message given by icc is the following:
error: this enclosing-function local variable cannot be referenced in this
lambda body because an enclosing lambda does not allow implicit captures
Godbolt : https://gcc.godbolt.org/z/rmefHT
Sample code for the issue:
struct S
{
void f() {
[]() {
[this]() {
}();
}();
}
};
int main()
{
S s;
s.f();
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs