public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111944] New: Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og)
@ 2023-10-23 20:34 ed at catmur dot uk
  2023-10-23 20:40 ` [Bug c++/111944] " ed at catmur dot uk
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ed at catmur dot uk @ 2023-10-23 20:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111944

            Bug ID: 111944
           Summary: Spurious '<anonymous>' is used uninitialized in
                    Boost.Variant2 (-Wuninitialized -Og)
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ed at catmur dot uk
  Target Milestone: ---

Since 12.1, with Boost 1.71 or later,

#include <boost/variant2/variant.hpp>
int main() {
    boost::variant2::variant<boost::variant2::monostate, int> r;
    r.emplace<boost::variant2::monostate>();
}

In member function 'constexpr void
boost::variant2::detail::variant_storage_impl<std::integral_constant<bool,
true>, T1, T ...>::emplace_impl(boost::mp11::mp_true,
boost::mp11::mp_size_t<I>, A&& ...) [with long unsigned int I = 1; A = {}; T1 =
boost::variant2::detail::none; T = {boost::variant2::monostate, int}]',
    inlined from 'constexpr void
boost::variant2::detail::variant_storage_impl<std::integral_constant<bool,
true>, T1, T ...>::emplace(boost::mp11::mp_size_t<I>, A&& ...) [with long
unsigned int I = 1; A = {}; T1 = boost::variant2::detail::none; T =
{boost::variant2::monostate, int}]' at boost/variant2/variant.hpp:705:27,
    inlined from 'constexpr void
boost::variant2::detail::variant_base_impl<true, true, T
...>::emplace_impl(boost::mp11::mp_true, A&& ...) [with long unsigned int J =
1; U = boost::variant2::monostate; A = {}; T = {boost::variant2::monostate,
int}]' at boost/variant2/variant.hpp:902:20,
    inlined from 'constexpr void
boost::variant2::detail::variant_base_impl<true, true, T ...>::emplace(A&& ...)
[with long unsigned int I = 0; A = {}; T = {boost::variant2::monostate, int}]'
at boost/variant2/variant.hpp:921:33,
    inlined from 'constexpr U& boost::variant2::variant<T>::emplace(A&& ...)
[with U = boost::variant2::monostate; A = {}; E = void; T =
{boost::variant2::monostate, int}]' at boost/variant2/variant.hpp:1690:49:
boost/variant2/variant.hpp:696:9: warning: '<anonymous>' is used uninitialized
[-Wuninitialized]
  696 |         *this = variant_storage_impl( mp11::mp_size_t<I>(),
std::forward<A>(a)... );
      |         ^
boost/variant2/variant.hpp: In member function 'constexpr U&
boost::variant2::variant<T>::emplace(A&& ...) [with U =
boost::variant2::monostate; A = {}; E = void; T = {boost::variant2::monostate,
int}]':
boost/variant2/variant.hpp:696:17: note: '<anonymous>' declared here
  696 |         *this = variant_storage_impl( mp11::mp_size_t<I>(),
std::forward<A>(a)... );
      |                
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Boost.Variant2 has a suppression at this line for Wmaybe-uninitialized
referencing asan, (a) this isn't with sanitizer, and (b) it's Wuninitialized.
This only appears to affect -Og, though, so fairly minor.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/111944] Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og)
  2023-10-23 20:34 [Bug c++/111944] New: Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og) ed at catmur dot uk
@ 2023-10-23 20:40 ` ed at catmur dot uk
  2023-10-23 22:39 ` [Bug tree-optimization/111944] " pinskia at gcc dot gnu.org
  2023-10-23 22:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ed at catmur dot uk @ 2023-10-23 20:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111944

--- Comment #1 from Ed Catmur <ed at catmur dot uk> ---
Correction, it does affect sanitizers (-O2 -fsanitize=address) as well as -Og.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/111944] Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og)
  2023-10-23 20:34 [Bug c++/111944] New: Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og) ed at catmur dot uk
  2023-10-23 20:40 ` [Bug c++/111944] " ed at catmur dot uk
@ 2023-10-23 22:39 ` pinskia at gcc dot gnu.org
  2023-10-23 22:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-23 22:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111944

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Spurious '<anonymous>' is   |Spurious '<anonymous>' is
                   |used uninitialized in       |used uninitialized in
                   |Boost.Variant2              |Boost.Variant2
                   |(-Wuninitialized            |(-Wuninitialized -Og)
                   |-Og/-fsanitize=address)     |

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well for fsanitize=address we document:

> Note that sanitizers tend to increase the rate of false positive warnings, most notably those around -Wmaybe-uninitialized. We recommend against combining -Werror and [the use of] sanitizers.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/111944] Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og)
  2023-10-23 20:34 [Bug c++/111944] New: Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og) ed at catmur dot uk
  2023-10-23 20:40 ` [Bug c++/111944] " ed at catmur dot uk
  2023-10-23 22:39 ` [Bug tree-optimization/111944] " pinskia at gcc dot gnu.org
@ 2023-10-23 22:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-23 22:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111944

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The IR definitely says it is unitialized:
  union variant_storage_impl D.73643;

  <bb 2> :
  boost::variant2::detail::variant_storage_impl<std::integral_constant<bool,
true>, boost::variant2::detail::none, boost::variant2::monostate,
int>::variant_storage_impl<1> (&D.73643, D.77838);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-23 22:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 20:34 [Bug c++/111944] New: Spurious '<anonymous>' is used uninitialized in Boost.Variant2 (-Wuninitialized -Og) ed at catmur dot uk
2023-10-23 20:40 ` [Bug c++/111944] " ed at catmur dot uk
2023-10-23 22:39 ` [Bug tree-optimization/111944] " pinskia at gcc dot gnu.org
2023-10-23 22:47 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).