================ @@ -361,6 +368,13 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, } return GV; } + if (!getLangOpts().CPlusPlus) { + // In C, when an initializer is given, the Linux kernel relies on clang to + // zero-initialize all members not explicitly initialized, including padding + // bits. ---------------- rjmccall wrote:
> > But I assume that similar code is required in order to explicitly zero out > > any padding when dynamically initializing a local variable. > > I guess you mean variables assigned by Compound literals after variable > definition. An example is in https://godbolt.org/z/caaEKnjWe. No, I mean initializing a local aggregate with a non-constant initializer, e.g. ``` void g(char c) { struct A a = { c, 2 }; } ``` Do we already zero the padding correctly in this case? https://github.com/llvm/llvm-project/pull/97121 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits