Skip to content

Commit

Permalink
[Fix] avoid unexpected throw in AttrInitEntry (#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzz2007 authored Aug 3, 2020
1 parent 3684a51 commit 84e3c19
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/tvm/ir/attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -463,7 +475,7 @@ class AttrInitVisitor {
} else {
opt.value_missing_ = true;
}
return opt;
return std::move(opt);
}

private:
Expand Down

0 comments on commit 84e3c19

Please sign in to comment.