[clang] [libcxx] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)
Nathan Chancellor via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 09:50:42 PDT 2024
nathanchance wrote:
> @nathanchance could you share your preprocessed source so that I can get a reproducer? Thanks!
Sure thing!
```
$ clang --target=x86_64-linux-gnu -fcf-protection -fsyntax-only -Wno-{address-of-packed-member,constant-logical-operand,gnu,unused-value} -Wnontrivial-memaccess rings.i
rings.i:95832:214: warning: first argument in call to '__builtin_memset' is a pointer to non-trivially copyable type 'struct nfp_nfd3_tx_desc' [-Wnontrivial-memaccess]
95832 | ({ size_t __fortify_size = (size_t)(tx_ring->size); fortify_memset_chk(__fortify_size, __builtin_dynamic_object_size(tx_ring->txds, 0), __builtin_dynamic_object_size(tx_ring->txds, 1)), __builtin_memset(tx_ring->txds, 0, __fortify_size); });
| ^
rings.i:95832:214: note: explicitly cast the pointer to silence this warning
95832 | ({ size_t __fortify_size = (size_t)(tx_ring->size); fortify_memset_chk(__fortify_size, __builtin_dynamic_object_size(tx_ring->txds, 0), __builtin_dynamic_object_size(tx_ring->txds, 1)), __builtin_memset(tx_ring->txds, 0, __fortify_size); });
| ^
| (void*)
1 warning generated.
```
[rings.i.txt](https://github.com/user-attachments/files/17560453/rings.i.txt)
https://github.com/llvm/llvm-project/pull/111434
More information about the cfe-commits
mailing list