3

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?

463035818_is_not_a_number
  • 88,680
  • 9
  • 76
  • 150

1 Answers1

2

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.)

Eric Postpischil
  • 168,892
  • 12
  • 149
  • 276