Open chrchr-github opened 1 month ago
@llvm/issue-subscribers-clang-static-analyzer
Author: None (chrchr-github)
It's unfortunate - but true - that we don't make the assumption that a default constructed vector
is empty - hence it should not take the second loop; so I think we can reduce this case into https://godbolt.org/z/19s5f6chG :
#include <vector>
int f() {
const int* p = nullptr;
std::vector<int> w;
return w.empty() ? 0 : *p; // FP on the dead ternary branch
}
p
is assigned before any element is placed intow
. https://godbolt.org/z/WxPv13qz9