Hello. The following code does not generate access of a moved variable warning when it should.
class MyClass { public: explicit MyClass(std::vector<int> vec) : vec1_(std::move(vec)) , vec2_(vec) {} private: std::vector<int> vec1_; std::vector<int> vec2_; };
Which version do you use? With head, I get
bar.cpp:5:17: warning: inconclusive: Access of moved variable 'vec'. [accessMoved] , vec2_(vec) ^ bar.cpp:4:17: note: Calling std::move(vec) : vec1_(std::move(vec)) ^ bar.cpp:5:17: note: Access of moved variable 'vec'. , vec2_(vec) ^
I am using version 2.9 for Windows, both GUI and console versions ignore this problem.
$ /c/Program\ Files/Cppcheck/cppcheck.exe --std=c++17 --language=c++ --file-filter=*.cpp --xml --output-file="out.xml" --enable=style . Checking main.cpp ...
If I add move and access of vec to constructor body, problem gets reported. If I add only access of vec, problem is still not reported.
I guess I'll just wait for a new version then.
Log in to post a comment.
Hello.
The following code does not generate access of a moved variable warning when it should.
Which version do you use? With head, I get
I am using version 2.9 for Windows, both GUI and console versions ignore this problem.
If I add move and access of vec to constructor body, problem gets reported.
If I add only access of vec, problem is still not reported.
I guess I'll just wait for a new version then.
Last edit: Alexander Khramtsovskiy 2022-12-09