[clang] [clang][CodeGen] The linux kernel expects initializers to FULLY initialize variables, structs and unions including padding (PR #97121)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 31 14:56:37 PDT 2024
================
@@ -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:
Comments in the compiler generally shouldn't refer to specific projects. We are making a guarantee based on our interpretation of the standard.
Similarly, the PR title is also inappropriate. It is fine to note in the PR description that Linux relies on this for correctness, but the PR title should describe the semantic change.
https://github.com/llvm/llvm-project/pull/97121
More information about the cfe-commits
mailing list