This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GTY variable_size & documentation
- From: Laurynas Biveinis <laurynas dot biveinis at gmail dot com>
- To: basile at starynkevitch dot net
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 14 Jul 2010 09:31:23 +0300
- Subject: Re: GTY variable_size & documentation
- References: <1279032857.7459.17.camel@glinka>
Hi,
2010/7/13 Basile Starynkevitch <basile@starynkevitch.net>:
> ÂThe type machinery then provides allocators that take a parameter indicating an exact size of object being allocated (like malloc does)
>
> and the exemple should better be
>
>
> ÂThen the objects of struct sorted_fields_type are allocated in GC memory as follows, assuming n is the number of elements:
>
> Â Â Â Â field_vec = ggc_alloc_sorted_fields_type (sizeof(sorted_fields_type) + (n-1) * sizeof(tree));
I agree that these two changes would be an improvement.
> By the way, I would very much like that GCC code would assume that variable-sized struct-ures are permitted, and declare instead
> Â Â Â Âstruct GTY((variable_size)) sorted_fields_type {
> Â Â Â Â Â Â Â Â Â Âint len;
> Â Â Â Â Â Â Â Â Â Âtree GTY((length ("%h.len"))) elts[];
> Â Â Â Â Â Â Â Â};
>
> Perhaps such a transition is needed, or at least very useful, even before any transition to C++ ?
Flexible array member is a C99 feature, IIRC GCC sources require C90.
Cheers,
--
Laurynas