On Mon, Apr 14, 2014 at 9:44 AM, Eric Botcazou <ebotca...@adacore.com> wrote:
> Hi,
>
> in Ada types can be very dynamic: not only can their shape depend on variables
> but it can also depend on the object itself (these are called self-referential
> types).  This raises interesting compile-time issues when you have dozens of
> dynamic fields in a record type, or dozens of nested dynamic record types, as
> every offset or size calculation is a fully-fledged expression in the GENERIC
> language and they can quickly add up if you are not careful.
>
> This is dealt with in stor-layout.c by means of the variable_size function,
> which ensures that these expressions are evaluated only once instead of being
> duplicated again and again as the complexity grows up.  The problem is that it
> is only called for size expressions (DECL_SIZE and DECL_SIZE_UNIT), which is
> fine for nested types, but not for offsets, which means that you will have a
> memory explosion for flat types with dozens of consecutive dynamic fields.
>
> The patch plugs the hole by invoking it for DECL_FIELD_OFFSET as well (and the
> effect is spectacular for pathological cases).  Tested on x86_64-suse-linux,
> although this will essentially only affect Ada.  OK for the mainline?

Ok.

Thanks,
Richard.

>
> 2014-04-14  Eric Botcazou  <ebotca...@adacore.com>
>
>         * stor-layout.c (place_field): Finalize non-constant offset for the
>         field, if any.
>
>
> --
> Eric Botcazou

Reply via email to