[clang] [NFC][analyzer] Extract general logic in security.ArrayBound (PR #210774)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 22 07:03:57 PDT 2026


================
@@ -410,3 +409,13 @@ int *nothingIsCertain(int x, int y) {
 
   return mem;
 }
+
+struct Empty {};
+struct Empty ZeroSizeElements[10];
+
+struct Empty zeroSizeElements(void) {
+  // FIXME: We probably shouldn't report this access.
+  return ZeroSizeElements[5];
+  // expected-warning at -1 {{Out of bound access to memory after the end of 'ZeroSizeElements'}}
+  // expected-note at -2 {{Access of 'ZeroSizeElements' at byte offset 0, while it holds only 0 byte}}
----------------
steakhal wrote:

BTW it reads a bit awkward that `byte` in the end is singular.

https://github.com/llvm/llvm-project/pull/210774


More information about the cfe-commits mailing list