Hi, I found false negatives regarding the rule accessMoved.
Cppcheck misses accesses through member-function calls after moving standard-library objects in the following programs.
Case 1: moved vector queried with empty()
#include<iostream>#include<utility>#include<vector>voidfoo(std::vector<int>);intmain(){std::vector<int>v={1,2,3};foo(std::move(v));if(!v.empty()){std::cout<<"Error: Vector not empty";}}
The vector v is moved into foo, then accessed by calling v.empty().
Hi, I found false negatives regarding the rule
accessMoved.Cppcheck misses accesses through member-function calls after moving standard-library objects in the following programs.
Case 1: moved vector queried with
empty()The vector
vis moved intofoo, then accessed by callingv.empty().Case 2: moved map queried with
find()The map
mis moved intofoo, then accessed by callingm.find(1).Case 3: moved string queried with
size()The string
sis moved intofoo, then accessed by callings.size().Actual result
Cppcheck reports no
accessMovedwarning for any of the three programs.Expected result
Cppcheck should report
accessMovedforv,m, andswhen they are accessed afterstd::move.Verification
The issue was reproduced with:
Version: 2.21.0
The warnings appear with
--inconclusive.