From e73d647752e25cd9f0241170bd78c623cebcda01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E4=BA=8E=E6=96=8C?= <1931127624@qq.com> Date: Sun, 31 May 2020 20:39:39 +0800 Subject: [PATCH] [bug] [ir] Fix Block::replace_with segment faults when stmts.size() == 0 (#1072) --- taichi/ir/ir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taichi/ir/ir.cpp b/taichi/ir/ir.cpp index 5fb2fdf644397..d30674c339a96 100644 --- a/taichi/ir/ir.cpp +++ b/taichi/ir/ir.cpp @@ -757,7 +757,7 @@ void Block::replace_with(Stmt *old_statement, } } TI_ASSERT(location != -1); - if (replace_usages) + if (replace_usages && !new_statements.stmts.empty()) old_statement->replace_with(new_statements.back().get()); trash_bin.push_back(std::move(statements[location])); if (new_statements.size() == 1) {