You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive: ConstParameterNotModified.Pointer on a pointee modified in a lambda #188
ConstParameterNotModified.Pointer suggests const for a pointer parameter whose pointee is modified through a lambda that captures the parameter by reference.
$ stack_usage_analyzer lambda-modifies-pointee.cpp
at line 6, column 0
[ !Info! ] ConstParameterNotModified.Pointer: parameter 'counter' in function 'count_through_lambda(int, Counter*)' is never used to modify the pointed object
↳ current type: Counter *counter
↳ suggested type: const Counter *counter
Why it is wrong
The lambda increments counter->count. With the suggested type, the file no longer compiles:
lambda-modifies-pointee.cpp:11:13: error: cannot assign to variable 'counter' with const-qualified type 'const Counter *'
Where it shows
The self-analysis reports it on computeSummary (src/analysis/ownership/OwnershipEngine.cpp), whose SummaryWork* work is incremented in the lambda solveCounted (#184).
Activity