Reputation: 29
In the Clang documentation page there is a fragment of following code:
struct seven_words {
int c[7];
};
void test() {
struct seven_words a, *p;
p = &a;
p[0] = a;
p[1] = a;
p[2] = a; // warn
}
Why the checker warns only at the line with accesing to p[2] whereas there is a segmentation fault on line p[1] = a;
. Is it a limit of the checker or there is something that I don't understand?
Upvotes: 3
Views: 93
Reputation: 223804
The documentation is incorrect. (Or, if it correctly documents the behavior of the analyzer, the analyzer is deficient because it fails to detect a clear problem.)
Upvotes: 2