[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:20 PST 2026


================
@@ -243,11 +243,12 @@ template <int A, int B>
 void call_memcpy_dep() {
   char bufferA[A];
   char bufferB[B];
-  memcpy(bufferA, bufferB, 10); // expected-warning{{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}}
+  memcpy(bufferA, bufferB, 10); // expected-warning{{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}} \
+                                // expected-warning{{'memcpy' reading 10 bytes from a region of size 9}}
----------------
erichkeane wrote:

Use the 'bookmarks' feature of verifiy-diagnostics-consumer to put these warnings next to the 'note' /instantiation below, else these are incredibly confusing.

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


More information about the cfe-commits mailing list