[clang] [clang] Fix 71315698c9 in presence of incomplete types (PR #114095)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 11:35:20 PDT 2024
================
@@ -8900,7 +8900,8 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
<< Call->getCallee()->getSourceRange());
else if (const auto *RT = PointeeTy->getAs<RecordType>()) {
- bool IsTriviallyCopyableCXXRecord =
+ bool MayBeTriviallyCopyableCXXRecord =
+ RT->isIncompleteType() ||
----------------
AaronBallman wrote:
Trivial copyability is about whether you can copy the object itself (aka, its members), and you can't create an object of incomplete class type or which contains an object of incomplete class type. So a pointer to an incomplete type is fine in that regard; it's just a pointer, you're not dereferencing it. However, for this diagnostic, `memcpy` and friends are touching the bytes of the object (so it's a dereference, effectively), and passing a pointer to an incomplete type means those are touching bytes of an unknown type which may be completed later.
https://github.com/llvm/llvm-project/pull/114095
More information about the cfe-commits
mailing list