diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 5d12744f7..94629c128 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3732,13 +3732,14 @@ private: } } AstPatMember* defaultp = nullptr; - for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; - patp = VN_AS(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;) { + AstPatMember* const nextp = VN_AS(patp->nextp(), PatMember); if (patp->isDefault()) { if (defaultp) nodep->v3error("Multiple '{ default: } clauses"); defaultp = patp; patp->unlinkFrBack(); } + patp = nextp; } while (const AstConstDType* const vdtypep = VN_CAST(dtypep, ConstDType)) { dtypep = vdtypep->subDTypep()->skipRefp();