[clang] [clang][CodeGen] Fix assertion failure with #embed in array new-expression initializers (PR #218262)

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 10:59:10 PDT 2026


================
@@ -563,7 +563,8 @@ class InitListChecker {
     // Reference just one if we're initializing a single scalar.
     uint64_t ElsCount = 1;
     // Otherwise try to fill whole array with embed data.
-    if (Entity.getKind() == InitializedEntity::EK_ArrayElement) {
+    if (Entity.getKind() == InitializedEntity::EK_ArrayElement &&
+        Entity.getType()->isScalarType()) {
----------------
akash-manna-sky wrote:

Narrowed it to `isIntegerType() || isRealFloatingType()`, which matches the integer/floating split in `ExprConstant` and `CGExprConstant` (`isRealFloatingType` rather than `isFloatingType` since the latter includes `_Complex`). Added a `_Complex` double case to both tests to cover the per-element fallback.

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


More information about the cfe-commits mailing list