[clang] [clang] warn_{cstruct, cxxstruct}_memaccess are too agressive about initializers (PR #170577)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 3 23:40:46 PST 2025


================
@@ -10356,15 +10356,24 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
       bool NonTriviallyCopyableCXXRecord =
           getLangOpts().CPlusPlus && RD->isCompleteDefinition() &&
           !PointeeTy.isTriviallyCopyableType(Context);
+      // We don't warn about bzero or zero memsetting as these are an idiomatic
+      // mechanism for ensuring objects do not have stale data.
+      bool IsNonZeroInitMemcall = false;
----------------
cor3ntin wrote:

Maybe that should be initialized to `BId != Builtin::BIbzero` (I'm not quite sure how the new code handle non memset, non bzero builtins) - and also maybe call the variable `IsZeroInitMemcall` to avoid double negatives

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


More information about the cfe-commits mailing list