On Wed, 15 Jan 2025, Jakub Jelinek wrote: > Hi! > > For T with non-trivial destructors, we were destructing objects in the > vector on release only when not using auto storage of auto_vec. > > The following patch calls truncate (0) instead of m_vecpfx.m_num clearing, > and truncate takes care of that destruction: > unsigned l = length (); > gcc_checking_assert (l >= size); > if (!std::is_trivially_destructible <T>::value) > vec_destruct (address () + size, l - size); > m_vecpfx.m_num = size; > > Bootstrapped/regtested on x86_64-linux and i686-linux, plus tested on the > testcase from the PR under valgrind, ok for trunk?
OK and thanks for catching this - it escaped my search for the problem... Richard. > 2025-01-15 Jakub Jelinek <ja...@redhat.com> > > PR ipa/118400 > * vec.h (vec<T, va_heap, vl_ptr>::release): Call m_vec->truncate (0) > instead of clearing m_vec->m_vecpfx.m_num. > > --- gcc/vec.h.jj 2025-01-15 08:43:16.259249515 +0100 > +++ gcc/vec.h 2025-01-15 09:32:25.755433708 +0100 > @@ -2020,7 +2020,7 @@ vec<T, va_heap, vl_ptr>::release (void) > > if (using_auto_storage ()) > { > - m_vec->m_vecpfx.m_num = 0; > + m_vec->truncate (0); > return; > } > > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)