diff --git a/src/script_opt/CPP/Types.cc b/src/script_opt/CPP/Types.cc index 68fdf48d11..b4ef3555fc 100644 --- a/src/script_opt/CPP/Types.cc +++ b/src/script_opt/CPP/Types.cc @@ -151,6 +151,10 @@ void CPPCompile::ExpandListTypeVar(const TypePtr& t, string& tn) void CPPCompile::ExpandRecordTypeVar(const TypePtr& t, string& tn) { auto r = t->AsRecordType()->Types(); + + if ( ! r ) + return; + auto t_name = tn + "->AsRecordType()"; AddInit(t, string("if ( ") + t_name + "->NumFields() == 0 )"); @@ -476,6 +480,9 @@ void CPPCompile::RegisterRecordType(const TypePtr& t) { auto r = t->AsRecordType()->Types(); + if ( ! r ) + return; + for ( auto i = 0; i < r->length(); ++i ) { const auto& r_i = (*r)[i];