Skip to content

Commit e65ed07

Browse files
committed
Disable -Wmaybe-uninitialized false positive. Refs #55.
1 parent 74f6f0c commit e65ed07

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

include/boost/variant2/variant.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,20 @@ template<class T1, class... T> union variant_storage_impl<mp11::mp_false, T1, T.
558558
T1 first_;
559559
variant_storage<T...> rest_;
560560

561+
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
562+
// false positive, see https://github.com/boostorg/variant2/issues/55
563+
# pragma GCC diagnostic push
564+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
565+
#endif
566+
561567
template<class... A> constexpr variant_storage_impl( mp11::mp_size_t<0>, A&&... a ): first_( std::forward<A>(a)... )
562568
{
563569
}
564570

571+
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
572+
# pragma GCC diagnostic pop
573+
#endif
574+
565575
template<std::size_t I, class... A> constexpr variant_storage_impl( mp11::mp_size_t<I>, A&&... a ): rest_( mp11::mp_size_t<I-1>(), std::forward<A>(a)... )
566576
{
567577
}
@@ -704,6 +714,7 @@ template<class T1, class... T> union variant_storage_impl<mp11::mp_true, T1, T..
704714
# pragma GCC diagnostic ignored "-Wuninitialized"
705715
#endif
706716
#endif
717+
707718
*this = variant_storage_impl( mp11::mp_size_t<I>(), std::forward<A>(a)... );
708719

709720
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
@@ -1119,8 +1130,18 @@ template<class... T> struct variant_base_impl<false, true, T...>
11191130

11201131
static_assert( std::is_nothrow_move_constructible<U>::value, "Logic error: U must be nothrow move constructible" );
11211132

1133+
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
1134+
// false positive, see https://github.com/boostorg/variant2/issues/55
1135+
# pragma GCC diagnostic push
1136+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
1137+
#endif
1138+
11221139
U tmp( std::forward<A>(a)... );
11231140

1141+
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
1142+
# pragma GCC diagnostic pop
1143+
#endif
1144+
11241145
_destroy();
11251146

11261147
st_.emplace( mp11::mp_size_t<J>(), std::move(tmp) );

0 commit comments

Comments
 (0)