Skip to content

Commit

Permalink
Revert copy-constructor modification which causes TVM segfaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch committed Apr 28, 2022
1 parent 20ec5be commit d71e29f
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions include/dmlc/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,17 @@ class optional {
optional() : is_none(true) {}
/*! \brief constructs an object that does contain a nullopt value. */
optional(dmlc::nullopt_t) noexcept : is_none(true) {} // NOLINT(*)
/*! \brief copy constructor, if other contains a value, then stored value is
* direct-intialized with it. */
optional(const optional &other) = default;
/*! \brief move constructor: If other contains a value, then stored value is
* direct-intialized with it. */
optional(optional &&other) noexcept(
std::is_nothrow_move_constructible<T>::value
&&std::is_nothrow_move_assignable<T>::value) {
if (!other.has_value()) {
reset();
} else if (has_value()) {
**this = std::move(*other);
} else {
new (&val) T(std::move(*other));
is_none = false;
/*! \brief construct an optional object with another optional object */
optional(const optional<T>& other) {
#pragma GCC diagnostic push
#if __GNUC__ >= 6
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
is_none = other.is_none;
if (!is_none) {
new (&val) T(other.value());
}
#pragma GCC diagnostic pop
}
/*! \brief constructs an optional object that contains a value, initialized as
* if direct-initializing */
Expand Down

0 comments on commit d71e29f

Please sign in to comment.