-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed as not planned
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerduplicateResolved as duplicateResolved as duplicatequestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
Compilation of the following code produces 2 warnings about potential null pointer dereference and null pointer dereference when compiled by the gcc with flags -O2 -Wnull-dereference.
This code contains ub and compiler is not obligated to warn about it, but is it possible to add additional warning option to the clang so that it reports about possible null pointer dereference like gcc does?
#include <cstdint>
#include <vector>
auto f(std::uint32_t n) {
std::vector<std::int32_t> v(n + 1);
v[0] = 1;
return v;
}
int main() {
f(static_cast<std::uint32_t>(-1));
}On the godbolt
https://godbolt.org/z/4q4bqcx5G
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerduplicateResolved as duplicateResolved as duplicatequestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!