================
@@ -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.
----------------
efriedma-quic wrote:

Adding handling for C++ is tricky: C++ allows fields and base classes to 
overlap.  For static initialization, it's straightforward to check for overlap, 
but for dynamic initialization it's problematic.  In some cases 
(AggValueSlot::DoesNotOverlap), we can prove there is no overlap, but in 
general it's ambiguous.   In such cases, we have to leave padding 
uninitialized.  So I think sticking to C for the first iteration makes sense; 
we'll have to carefully consider exactly what guarantees we can provide for C++.

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

Reply via email to