Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] avoid unexpected throw in AttrInitEntry #6128

Merged
merged 2 commits into from Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion include/tvm/ir/attrs.h
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