[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 11:36:49 PDT 2024


================
@@ -738,7 +738,7 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) {
     // Zero-sized fields are not emitted, but their initializers may still
     // prevent emission of this struct as a constant.
     if (isEmptyFieldForLayout(CGM.getContext(), Field)) {
-      if (Init->HasSideEffects(CGM.getContext()))
+      if (Init && Init->HasSideEffects(CGM.getContext()))
----------------
efriedma-quic wrote:

Looking at the comments ("Only do this if we're initializing a class type, to avoid filling in the initializer list where possible"), I guess the member init is being intentionally omitted to try to reduce the size of the AST... but for C++11 classes, we need to do overload resolution etc., so we can't skip it.

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


More information about the cfe-commits mailing list