This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/Ada] guard against a malloc failure
- From: Jerome Guitton <guitton at adacore dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 12 Dec 2008 19:40:06 +0100
- Subject: Re: [RFA/Ada] guard against a malloc failure
- References: <20081127145701.GB3835@adacore.com> <20081209095142.GL3823@adacore.com> <20081212155749.GA18970@adacore.com>
Jerome Guitton (guitton@adacore.com):
> 2008-12-12 Jerome Guitton <guitton@adacore.com>
>
> * ada-lang.c (ada_template_to_fixed_record_type_1): Allocate dval
> before a dynamic field is added.
Not quite right actually. The assumption that all discriminants are
emitted before any dynamic field is wrong. Consider:
type X (Dx : Integer) is tagged record
Vx : String (1 .. Dx);
end record;
type Y (Dx : Integer; Dy : Integer) is new X (Dx => Dx) with record
Vy : String (1 .. Dy);
end record;
The layout of Y's fields in memory will be: Dx, Vx, Y, Vy.
Apparently the patch does not fail on this case, but I do not
understand why. This needs to be clarified. Standby...