================
@@ -1305,7 +1305,21 @@ void 
CIRGenFunction::emitNullInitialization(mlir::Location loc, Address destPtr,
   // TODO: there are other patterns besides zero that we can usefully memset,
   // like -1, which happens to be the pattern used by member-pointers.
   if (!cgm.getTypes().isZeroInitializable(ty)) {
-    cgm.errorNYI(loc, "type is not zero initializable");
+    // Classic codegen handles non-zero-init VLAs here via emitNonZeroVLAInit.
+    // In CIR, getTypeSizeInChars returns 0 for VLAs, so they are caught by
+    // the errorNYI above.
+    //
+    // Guard: emitNullConstant calls errorNYI for virtual bases and returns {},
+    // which would crash builder.getConstant; report the NYI here instead.
+    if (const auto *rd = ty->getAsCXXRecordDecl(); rd && rd->getNumVBases()) {
+      cgm.errorNYI(loc,
+                   "emitNullInitialization: non-zero-init type with virtual "
+                   "bases");
+      return;
+    }
+    mlir::Value nullVal = cgm.emitNullConstant(ty, loc);
----------------
erichkeane wrote:

At the moment, until we can get better testing, we should assert here for a 
`ty` that doesn't match the Pointer-to-Data-member case.  Unless we have a test 
here that makes sure we match the LLVM variant of it, we need to assert.

https://github.com/llvm/llvm-project/pull/201654
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to