Skip to content

Commit

Permalink
Merge pull request #596 from leezu/fixoptional
Browse files Browse the repository at this point in the history
Disable GCC v6+ -Wmaybe-uninitialized in optional.h
  • Loading branch information
szha authored Mar 3, 2020
2 parents cce75c1 + 4e90853 commit c8f7f9c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/dmlc/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,25 @@ class optional {
optional() : is_none(true) {}
/*! \brief construct an optional object with value */
explicit optional(const T& value) {
#pragma GCC diagnostic push
#if __GNUC__ >= 6
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
is_none = false;
new (&val) T(value);
#pragma GCC diagnostic pop
}
/*! \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 deconstructor */
~optional() {
Expand Down

0 comments on commit c8f7f9c

Please sign in to comment.