Issue 101635
Summary [clang] False positive clang-analyzer-core.NonNullParamChecker with guard variable and two containers
Labels clang
Assignees
Reporter chrchr-github
    ~~~c++
#include <vector>

int f(const std::vector<int>& v) {
	const int* p = nullptr;
	bool b = false;
	std::vector<int> w;
	for (const auto& i : v) {
		if (!b) {
			p = &i;
			b = true;
 }
		else
			w.emplace_back(i);
	}
	int x = 0;
	for (auto j : w) {
		x = std::max(*p, j);
	}
	return x;
}
~~~
`p` is assigned before any element is placed into `w`.
https://godbolt.org/z/WxPv13qz9
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to