This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80635] std::optional and bogus -Wmaybe-uninitialized warning
- From: "palves at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 05 May 2017 11:20:10 +0000
- Subject: [Bug c++/80635] std::optional and bogus -Wmaybe-uninitialized warning
- Auto-submitted: auto-generated
- References: <bug-80635-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
--- Comment #6 from Pedro Alves <palves at redhat dot com> ---
That kind of makes sense if you look at optional<T> in isolation, but why does
it _not_ warn if you remove anything related to B and leave only A? That's
what's truly mystifying to me.
Even this change makes the warning go away:
void func ()
{
Optional<A> maybe_a;
- Optional<B> maybe_b; // for some reason, need this here to trigger a
+ Optional<A> maybe_b; // for some reason, need this here to trigger a
// warning in _A_.
maybe_a.emplace ();
maybe_b.emplace (); // comment out, and the warning disappears.
}