On Fri, Jul 01, 2022 at 04:12:55PM +0200, Aldy Hernandez wrote: > > --- a/gcc/wide-int.h > > +++ b/gcc/wide-int.h > > @@ -1373,10 +1373,13 @@ namespace wi > > : public int_traits <wide_int_storage> {}; > > } > > > > -/* An array of N wide_int-like objects that can be put at the end of > > - a variable-sized structure. Use extra_size to calculate how many > > - bytes beyond the sizeof need to be allocated. Use set_precision > > - to initialize the structure. */ > > +/* A variable-lengthed array of wide_int-like objects that can be put > > + at the end of a variable-sized structure. The number of objects is > > + at most N and can be set at runtime by using set_precision(). > > + > > + Use extra_size to calculate how many bytes beyond the > > + sizeof need to be allocated. Use set_precision to initialize the > > + structure. */ > > template <int N> > > struct GTY((user)) trailing_wide_ints > > { > > @@ -1387,6 +1390,9 @@ private: > > /* The shared maximum length of each number. */ > > unsigned char m_max_len; > > > > + /* The number of elements. */ > > + unsigned char m_num_elements;
IMNSHO you certainly don't want to change like this existing trailing_wide_ints, you don't want to grow unnecessarily existing trailing_wide_ints users (e.g. const_poly_int_def). My brief understanding of wide-int.h is that in some cases stuff like this is implied from template parameters or exact class instantiation and in other cases it is present explicitly and class inheritence is used to hide that stuff nicely. So, you are looking for something like trailing_wide_ints<N> but where that N is actually a runtime value? Then e.g. the struct {unsigned char len;} m_len[N]; member can't work properly either, because it isn't constant size. Jakub