The following avoids default-initializing auto_vec storage for non-POD T since that's not what the allocated storage fallback will do and it's also not expected for existing cases like
auto_vec<std::pair<unsigned, unsigned>, 64> elts; which exist to optimize the allocation. Bootstrapped and tested on x86_64-unknown-linux-gnu. It saves around 1kB of text size for cc1. OK for trunk? Thanks, Richard. * vec.h (auto_vec<T, N>): Turn m_data storage into uninitialized unsigned char. --- gcc/vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/vec.h b/gcc/vec.h index a536b68732d..cee96254a31 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -1584,7 +1584,7 @@ public: private: vec<T, va_heap, vl_embed> m_auto; - T m_data[MAX (N - 1, 1)]; + alignas(T) unsigned char m_data[sizeof (T) * MAX (N - 1, 1)]; }; /* auto_vec is a sub class of vec whose storage is released when it is -- 2.35.3