#include <vector> struct A { void f() const { std::vector<int> v_s; for (const auto& s : v_) { v_s.emplace_back(s); } } std::vector<int> v_; }; This was reduced from a much bigger class where the variable was actually filled. If I make both members static or implement it with a function and a global warning the warning is being reported. Tested with version 11.0.1.
Proposed patch - https://reviews.llvm.org/D101624