https://bugs.kde.org/show_bug.cgi?id=485675
Bug ID: 485675 Summary: lambda-in-connect does not honor receiver context Classification: Developer tools Product: clazy Version: unspecified Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: unassigned-b...@kde.org Reporter: m...@milianw.de CC: smart...@kde.org Target Milestone: --- Created attachment 168616 --> https://bugs.kde.org/attachment.cgi?id=168616&action=edit patch to show failure in unit test SUMMARY lambda-in-connect seems smart enough to figure out if the sender is in the same stack frame as a capture, but does not take the receiver context into account STEPS TO REPRODUCE See attached patch OBSERVED RESULT ``` QObject o2; QObject::connect(&o2, &QObject::destroyed, [&m]() { m; }); // OK, o2 is on the stack QObject *o3; QObject::connect(o3, &QObject::destroyed, o3, [&o3] { o3; }); // OK, the captured variable is on the 3rd parameter too. It will get destroyed // this fails: QObject::connect(o3, &QObject::destroyed, &o2, [&m]() { m; }); // OK, o2 is on the stack ``` EXPECTED RESULT failure for constructs such as the last one, where `m` is on the stack and gets destroyed after `o2`. SOFTWARE/OS VERSIONS latest clazy master against clang 17.0.6 ADDITIONAL INFORMATION -- You are receiving this mail because: You are watching all bug changes.