Issue 124513
Summary Bogus warning: 'memset' will always overflow; destination buffer has size 1, but size argument is 2 [-Wfortify-source]
Labels new issue
Assignees
Reporter stbergmann
    On recent LLVM trunk (towards LLVM 20), bisecting shows that <https://github.com/llvm/llvm-project/commit/0a9c08c59ba61e727e9dee6d71883d9106963442> "[Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (https://github.com/llvm/llvm-project/pull/95474)" started to cause
```
$ cat test.cc
#include <cstring>
struct S { char m1, m2; };
void f(S & x) { std::memset(&x, 0, sizeof (S)); }
```
```
$ clang++ -std=c++23 -fsyntax-only test.cc
test.cc:3:17: warning: 'memset' will always overflow; destination buffer has size 1, but size argument is 2 [-Wfortify-source]
    3 | void f(S & x) { std::memset(&x, 0, sizeof (S)); }
      |                 ^
1 warning generated.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to