Skip to content

Commit ff710d1

Browse files
authored
Merge pull request #145 from alandefreitas/fix/maybe-uninitialized-pragma
fix: add -Wmaybe-uninitialized pragma to union storage constructors
2 parents fa52755 + 88e2378 commit ff710d1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

include/boost/optional/detail/union_optional.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,20 @@ union constexpr_union_storage_t
7474

7575
constexpr constexpr_union_storage_t( trivial_init_t ) noexcept : dummy_() {};
7676

77+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
78+
// false positive, see https://github.com/boostorg/variant2/issues/55,
79+
// https://github.com/boostorg/url/issues/979
80+
# pragma GCC diagnostic push
81+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
82+
#endif
83+
7784
template <class... Args>
7885
constexpr constexpr_union_storage_t( Args&&... args ) : value_(forward_<Args>(args)...) {}
7986

87+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
88+
# pragma GCC diagnostic pop
89+
#endif
90+
8091
//~constexpr_union_storage_t() = default; // No need to destroy a trivially-destructible type
8192
};
8293

@@ -88,9 +99,20 @@ union fallback_union_storage_t
8899

89100
constexpr fallback_union_storage_t( trivial_init_t ) noexcept : dummy_() {};
90101

102+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
103+
// false positive, see https://github.com/boostorg/variant2/issues/55,
104+
// https://github.com/boostorg/url/issues/979
105+
# pragma GCC diagnostic push
106+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
107+
#endif
108+
91109
template <class... Args>
92110
constexpr fallback_union_storage_t( Args&&... args ) : value_(forward_<Args>(args)...) {}
93111

112+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
113+
# pragma GCC diagnostic pop
114+
#endif
115+
94116
~fallback_union_storage_t(){} // My owner will destroy the `T` if needed.
95117
// Cannot default in a union with nontrivial `T`.
96118
};

0 commit comments

Comments
 (0)