On 1/21/25 11:15 AM, Jakub Jelinek wrote:
On Tue, Jan 21, 2025 at 11:06:35AM -0500, Jason Merrill wrote:
--- gcc/c-family/c-common.cc.jj 2025-01-20 18:00:35.667875671 +0100
+++ gcc/c-family/c-common.cc    2025-01-21 09:29:23.955582581 +0100
@@ -9010,33 +9010,46 @@ make_tree_vector_from_list (tree list)
     return ret;
   }
-/* Get a new tree vector of the values of a CONSTRUCTOR.  */
+/* Append to a tree vector the values of a CONSTRUCTOR.
+   nelts should be at least CONSTRUCTOR_NELTS (ctor) and v
+   should be initialized with make_tree_vector (); followed by
+   vec_safe_reserve (v, nelts); or equivalently vec_alloc (v, nelts);
+   optionally followed by pushes of other elements (up to
+   nelts - CONSTRUCTOR_NELTS (ctor)).  */

How about using v->allocated () instead of passing in nelts?

That is not necessarily the same.

Yeah, it occurred to me later that it doesn't matter what the original length or capacity of the vector is, we want to make sure there's enough room for the elements of the ctor after whatever's already there. So we want nelts to start as CONSTRUCTOR_NELTS, and then vec_safe_reserve nelts - i.

Does that make sense to you?

Jason

Reply via email to