diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index 785498a07..41a81e169 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -1277,8 +1277,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, } StmtDiff ReverseModeVisitor::VisitInitListExpr(const InitListExpr* ILE) { - if (!dfdx()) - return StmtDiff(Clone(ILE)); QualType ILEType = ILE->getType(); llvm::SmallVector clonedExprs(ILE->getNumInits()); if (isArrayOrPointerType(ILEType)) { @@ -1303,8 +1301,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // fetch ith field of the struct. auto field_iterator = ILEType->getAsCXXRecordDecl()->field_begin(); std::advance(field_iterator, i); - Expr* member_acess = utils::BuildMemberExpr( - m_Sema, getCurrentScope(), dfdx(), (*field_iterator)->getName()); + Expr* member_acess = nullptr; + if (dfdx()) + member_acess = utils::BuildMemberExpr( + m_Sema, getCurrentScope(), dfdx(), (*field_iterator)->getName()); clonedExprs[i] = Visit(ILE->getInit(i), member_acess).getExpr(); } Expr* clonedILE = m_Sema.ActOnInitList(noLoc, clonedExprs, noLoc).get();