Skip to content

Commit

Permalink
[Fix] avoid unexpected throw in AttrInitEntry (apache#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzz2007 authored and Trevor Morris committed Sep 2, 2020
1 parent fb0d726 commit 162a11f
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 162a11f

Please sign in to comment.