https://gcc.gnu.org/g:907b07fbeda458b608cf5fd6a4dec1935f4253b9

commit r17-796-g907b07fbeda458b608cf5fd6a4dec1935f4253b9
Author: Javier Miranda <[email protected]>
Date:   Thu Feb 12 11:02:57 2026 +0000

    ada: Missing initialization of aggregate components
    
    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).

Diff:
---
 gcc/ada/exp_ch4.adb | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 476508b7449d..490ecf8f8340 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12543,6 +12543,17 @@ package body Exp_Ch4 is
          --  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

Reply via email to