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

--- Comment #38 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #37)
>(because the warning is correct for the over-reduced optional):

This is better:

template<typename T>
struct optional
{
  optional () : m_dummy (), live (false) {}
  void emplace () { new (&m_item) T (); live = true; }
  ~optional () { if (live) m_item.~T (); }

  union
  {
    int m_dummy;
    T m_item;
  };
  bool live;
};

Reply via email to