Bug 443342

Summary: lambda-in-connect false positive, when a lambda is nested in another lambda
Product: [Developer tools] clazy Reporter: julien.cugniere
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: REPORTED ---    
Severity: normal CC: julien.cugniere, smartins, vaclav
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: lambda-in-connect-false-positive.cpp

Description julien.cugniere 2021-10-05 08:38:36 UTC
Created attachment 142163 [details]
lambda-in-connect-false-positive.cpp

SUMMARY

lambda-in-connect false positive when a capturing lambda is nested inside the connected lambda.

STEPS TO REPRODUCE

1. Run clazy on attached file lambda-in-connect-false-positive.cpp

OBSERVED RESULT

lambda-in-connect-false-positive.cpp(8,4): warning: captured local variable by reference might go out of scope before lambda is called [-Wclazy-lambda-in-connect]
                        foo++;

EXPECTED RESULT

No warning. The connected lambda is not capturing foo (only the nested lambda is), so there's no risk.

SOFTWARE/OS VERSIONS

Windows: 21H1
Qt Version: Qt 5.15.2
clazy_v1.8-msvc2019.zip as build by KDAB (File lambda-in-connect.cpp has no commits between 1.8 and master).

ADDITIONAL INFORMATION

If the connected lambda is capturing by reference something other than foo, the warning should still not appear.