Skip to content

Commit b6ce8ac

Browse files
committed
Add missing -Wmaybe-uninitialized pragma to recursive variant_storage_impl
The pragma added in the flat (10-member) specialization for #55 is missing from the recursive (T1, T...) specialization. GCC 14/15 at -O3 triggers the same false positive here when deeply inlining constexpr functions (e.g. system::result<url_view> construction). Refs #55
1 parent b137164 commit b6ce8ac

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/boost/variant2/variant.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ template<class T1, class... T> union variant_storage_impl<mp11::mp_false, T1, T.
625625
T1 first_;
626626
variant_storage<T...> rest_;
627627

628-
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
628+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
629629
// false positive, see https://github.com/boostorg/variant2/issues/55
630630
# pragma GCC diagnostic push
631631
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
@@ -635,7 +635,7 @@ template<class T1, class... T> union variant_storage_impl<mp11::mp_false, T1, T.
635635
{
636636
}
637637

638-
#if defined(BOOST_GCC) && (__GNUC__ >= 12)
638+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
639639
# pragma GCC diagnostic pop
640640
#endif
641641

@@ -752,10 +752,20 @@ template<class T1, class... T> union variant_storage_impl<mp11::mp_true, T1, T..
752752
T1 first_;
753753
variant_storage<T...> rest_;
754754

755+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
756+
// false positive, see https://github.com/boostorg/variant2/issues/55
757+
# pragma GCC diagnostic push
758+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
759+
#endif
760+
755761
template<class... A> constexpr variant_storage_impl( mp11::mp_size_t<0>, A&&... a ): first_( std::forward<A>(a)... )
756762
{
757763
}
758764

765+
#if defined(BOOST_GCC) && (__GNUC__ >= 7)
766+
# pragma GCC diagnostic pop
767+
#endif
768+
759769
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)... )
760770
{
761771
}

0 commit comments

Comments
 (0)