Fznamznon wrote: I'm trying to insert a cast using emitCast: ``` --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1347,6 +1347,13 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits, }
auto Eval = [&](Expr *Init, unsigned ElemIndex) { + auto ArrayTy = Ctx.getASTContext().getAsConstantArrayType(T); + std::optional<PrimType> FromT = classify(Init->getType()); + std::optional<PrimType> ToT = classify(ArrayTy->getElementType()); + if (FromT != ToT) { + if (!this->emitCast(*FromT, *ToT, Init)) + return false; + } return visitArrayElemInit(ElemIndex, Init); }; ``` But it fails with an assertion ``` source/llvm-project/clang/lib/AST/Interp/InterpStack.h:46: T clang::interp::InterpStack::pop() [with T = clang::interp::Integral<8, false>]: Asserti on `ItemTypes.back() == toPrimType<T>()' failed. ``` https://github.com/llvm/llvm-project/pull/95802 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits