Missing initialization of aggregate components in Ada
Fixes a bug in Ada where tagged type conversions of qualified aggregate expressions could leave some components uninitialized.
This commit fixes a bug in the Ada compiler where tagged type conversions applied to qualified expressions of aggregates could result in some components being left uninitialized at runtime. To ensure full initialization of the tagged object, the fix forces the evaluation of the aggregate expression by capturing its value in a constant.
In Details
The fix addresses an issue in exp_ch4.adb's Expand_N_Type_Conversion function. When handling a qualified expression of an aggregate, the operand was not being fully evaluated, leading to uninitialized components in the tagged object. The change ensures that the value is captured in a constant, forcing complete initialization.
For Context
In Ada, a tagged type is similar to a class in other languages. Aggregate types are composite data structures like structs or records. This commit addresses a scenario where converting an aggregate to a tagged type using a qualified expression (specifying the type) could lead to uninitialized fields within the object. The fix ensures that the expression is fully evaluated, guaranteeing that all components are properly initialized.