diff --git a/src/libasr/codegen/asr_to_llvm.cpp b/src/libasr/codegen/asr_to_llvm.cpp index 122834ab39..7de6a1fa3a 100644 --- a/src/libasr/codegen/asr_to_llvm.cpp +++ b/src/libasr/codegen/asr_to_llvm.cpp @@ -5134,6 +5134,11 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor } inline void visit_expr_wrapper(ASR::expr_t* x, bool load_ref=false) { + // Check if *x is nullptr. + if( x == nullptr ) { + throw CodeGenError("Internal error: x is nullptr"); + } + this->visit_expr(*x); if( x->type == ASR::exprType::ArrayItem || x->type == ASR::exprType::ArraySection ||