[clang] [analyzer] Fix handling of zero-sized elements in ArrayBound (PR #218712)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 06:03:52 PDT 2026


================
@@ -475,9 +475,41 @@ struct Empty {};
 struct Empty ZeroSizeElements[10];
 
 struct Empty zeroSizeElements(void) {
-  // FIXME: We probably shouldn't report this access.
-  return ZeroSizeElements[5];
+  // Previously this had produced the false positive warning {{Access of
+  // 'ZeroSizeElements' at byte offset 0, while it holds only 0 bytes}}.
+  return ZeroSizeElements[5]; // no-warning
----------------
NagyDonat wrote:

I rewrote the comment in https://github.com/llvm/llvm-project/pull/218712/commits/98b7635097293c436500652e4a687bda6f54fd63

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


More information about the cfe-commits mailing list