[PATCH] D104285: [analyzer][AST] Retrieve value by direct index from list initialization of constant array declaration.

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 17 06:22:31 PDT 2021


ASDenysPetrov added a comment.

@aaron.ballman
Ok, I got your concerns. As I can see we shall only reason about objects within the bounds. Otherwise, we shall return `UndefinedVal`.
E.g.:

  int arr[2][5];
  int* ptr1= (int*)arr; // Valid indexing for `ptr` is in range [0,4].
  int* ptr2 = &arr[0][0]; // Same as above.
  ptr1[4]; // Valid object.
  ptr2[5]; // Out of bound. UB. UndefinedVal.

Would it be correct?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104285/new/

https://reviews.llvm.org/D104285



More information about the cfe-commits mailing list