From 8582136a459c6ac38c1edcab9ed0e8c563ddfe73 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 12 Aug 2025 12:39:36 +0200 Subject: [PATCH] simplify: fix $initstate segfault --- frontends/ast/simplify.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index c25d0183f..b1a615d76 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -3369,13 +3369,14 @@ skip_dynamic_range_lvalue_expansion:; wire->str = stringf("$initstate$%d_wire", myidx); while (wire->simplify(true, 1, -1, false)) { } - auto cell = std::make_unique(location, AST_CELL, std::make_unique(location, AST_CELLTYPE), std::make_unique(location, AST_ARGUMENT, std::make_unique(location, AST_IDENTIFIER))); + auto cell_owned = std::make_unique(location, AST_CELL, std::make_unique(location, AST_CELLTYPE), std::make_unique(location, AST_ARGUMENT, std::make_unique(location, AST_IDENTIFIER))); + auto* cell = cell_owned.get(); cell->str = stringf("$initstate$%d", myidx); cell->children[0]->str = "$initstate"; cell->children[1]->str = "\\Y"; cell->children[1]->children[0]->str = wire->str; cell->children[1]->children[0]->id2ast = wire; - current_ast_mod->children.push_back(std::move(cell)); + current_ast_mod->children.push_back(std::move(cell_owned)); while (cell->simplify(true, 1, -1, false)) { } newNode = std::make_unique(location, AST_IDENTIFIER);