[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 14:05:38 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:
Maybe we should look at making InitListExpr handling more consistent, though... it looks like we generate an implicit initializer expression for C++ classes, but not other cases. But this should do the right thing.
https://github.com/llvm/llvm-project/pull/109271
More information about the cfe-commits
mailing list