diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-01-16 09:17:50 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-01-16 09:27:53 +0100 |
commit | 43f4d44bebd63b354f8798fcef512d4d2b42c655 (patch) | |
tree | f7c032e23d598a95bac57b3cb6a60b36b5c967d7 | |
parent | 3872daa5767622d1f8b086050996c85604db7514 (diff) | |
download | gcc-43f4d44bebd63b354f8798fcef512d4d2b42c655.zip gcc-43f4d44bebd63b354f8798fcef512d4d2b42c655.tar.gz gcc-43f4d44bebd63b354f8798fcef512d4d2b42c655.tar.bz2 |
vec.h: Properly destruct elements in auto_vec auto storage [PR118400]
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;
2025-01-16 Jakub Jelinek <jakub@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.
-rw-r--r-- | gcc/vec.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; } |