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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This code has undefined behaviour:

int main()
{
  FSPI pi;
  FSPG* pg = new FSPG();
  new (&pi.m_a) FSPGI(pg);
  pi.m_a.~FSPGI();
  return 0;
}

pi.m_a is part of an object on the stack, so its destructor will run
automatically. If you invoke it explicitly as pi.m_a.~FSPGI() then you cause
the same object to be destroyed twice. This is undefined. You need to fix your
code.

Reply via email to