From 84e3c1970c0def8f8615f23b75e2a4563059f3d5 Mon Sep 17 00:00:00 2001 From: qiuhan Date: Tue, 4 Aug 2020 03:29:55 +0800 Subject: [PATCH] [Fix] avoid unexpected throw in AttrInitEntry (#6128) --- include/tvm/ir/attrs.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/tvm/ir/attrs.h b/include/tvm/ir/attrs.h index 4cdf8c5..d20ba4f 100644 --- a/include/tvm/ir/attrs.h +++ b/include/tvm/ir/attrs.h @@ -337,6 +337,18 @@ struct AttrInitEntry { T* value_; // whether the value is missing. bool value_missing_{true}; + + AttrInitEntry() = default; + + AttrInitEntry(AttrInitEntry&& other) { + type_key_ = other.type_key_; + key_ = other.key_; + value_ = other.value_; + value_missing_ = other.value_missing_; + // avoid unexpected throw + other.value_missing_ = false; + } + // If the value is still missing in destruction time throw an error. ~AttrInitEntry() DMLC_THROW_EXCEPTION { if (value_missing_) { @@ -463,7 +475,7 @@ class AttrInitVisitor { } else { opt.value_missing_ = true; } - return opt; + return std::move(opt); } private: -- 2.7.4