When a tagged type conversion is applied to a qualified expression
of an aggregate, at runtime some components are left uninitialized.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Type_Conversion): When the operand is a
qualified expression of an aggregate, force its evaluation by
capturing its value in a constant (to ensure full initialization
of the tagged object).
-- Start of processing for Tagged_Conversion
begin
+ -- When the operand is a qualified expression of an aggregate,
+ -- force its evaluation by capturing its value in a constant
+ -- (to ensure full initialization of the tagged object).
+
+ if Nkind (Operand) = N_Qualified_Expression
+ and then Nkind (Expression (Operand)) in N_Aggregate
+ | N_Extension_Aggregate
+ then
+ Force_Evaluation (Operand, Mode => Strict);
+ end if;
+
-- Handle entities from the limited view
if Is_Access_Type (Operand_Type) then