[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

Endre Fülöp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 01:02:12 PDT 2020


gamesh411 accepted this revision.
gamesh411 added a comment.
This revision is now accepted and ready to land.

With the minor adjustment in the one test case this LGTM.



================
Comment at: clang/test/Analysis/vla.c:107
+  if (x == BIGINDEX) {
+    size_t s = sizeof(int[x][x][x][x]); // expected-warning{{Declared variable-length array (VLA) has too large size}}
+    return s;
----------------
martong wrote:
> I think we could make the arithmetic more clear here:
> x = BIGINDEX 65536 (2^16) and `char[x][x][x][x]` would be the first to overflow.
> And `char[x][x][x][x-1]` should not overflow.
> 
> And if we are at it, then `size_t`'s range is target dependent, so I think we must extend the `RUN` line with `-target`.
I would also find the extra comment and the extra passing test case helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330





More information about the cfe-commits mailing list