Bug 443342 - lambda-in-connect false positive, when a lambda is nested in another lambda
Summary: lambda-in-connect false positive, when a lambda is nested in another lambda
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-05 08:38 UTC by julien.cugniere
Modified: 2024-02-13 16:09 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
lambda-in-connect-false-positive.cpp (196 bytes, text/plain)
2021-10-05 08:38 UTC, julien.cugniere
Details

Note You need to log in before you can comment on or make changes to this bug.
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.