From ac257e4a865376b3c30f6b609c6bacf983afd8bb Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Wed, 5 May 2021 19:32:30 -0700 Subject: [PATCH] bug fixes for stand-alone compiles with empty records --- src/script_opt/CPP/Types.cc | 7 +++++++ 1 file changed, 7 insertions(+) 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];