[Bug c++/92912] New: Bad diagnostic for capture of this in free function
soko.slav at yandex dot ru
gcc-bugzilla@gcc.gnu.org
Wed Dec 11 12:13:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92912
Bug ID: 92912
Summary: Bad diagnostic for capture of this in free function
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: soko.slav at yandex dot ru
Target Milestone: ---
This free function
void foo()
{
[&]()
{
static_cast<void*>(this);
};
}
does not compile but the message is misleading:
error: 'this' was not captured for this lambda function
static_cast<void*>(this);
Actually 'this' cannot be captured here as 'this' is keyword which cannot be
used in this context.
Expected message:
error: invalid use of 'this' in non-member function
tested locally and on https://godbolt.org/z/5cAA3k (more examples there
including similar case without lambda)
More information about the Gcc-bugs
mailing list