[clang] [Clang][Sema] Add -Wstringop-overread warning for source buffer overreads (PR #183004)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 24 14:58:18 PST 2026


================
@@ -7,7 +7,8 @@
 /// Zero-sized structs should not crash.
 int b() {
   struct {      } a[10];
-  __builtin_memcpy(&a[2], a, 2); // c-warning {{buffer has size 0, but size argument is 2}}
+  __builtin_memcpy(&a[2], a, 2); // c-warning {{buffer has size 0, but size argument is 2}} \
+                                 // c-warning {{'memcpy' reading 2 bytes from a region of size 0}}
----------------
erichkeane wrote:

why is this only diagnosing C?  This is a problem in C++ as well.  Alos, in this case it is redundant with the existing warning, what are we adding here of value?

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


More information about the cfe-commits mailing list