[PATCH] PR123949 followup fixer

Jerry D <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
The attached patch is a followup on PR123949, a one liner.

The initial patch uncovered this latent patch.

I will commit shortly.

Regression tested on X86_64 and on aarch64 with LTO bootstrap.

Regards,

Jerry


Author: Christopher Albert <[email protected]>
Date:   Sun Feb 22 22:07:19 2026 +0100

     fortran: Initialize gfc_se in PDT component allocation [PR123949]

     Add missing gfc_init_se call for the default initializer case in
     ALLOCATE_PDT_COMP.  The adjacent KIND/LEN block (line 11118) and
     pdt_string block (line 11149) both initialize tse, but this block
     left it uninitialized, causing undefined behavior when tse.ss
     contained stack garbage.  Exposed as an ICE in gfc_conv_constant
     (trans-const.cc:425) on aarch64 with LTO bootstrap.

             PR fortran/123949

     gcc/fortran/ChangeLog:

             * trans-array.cc (structure_alloc_comps): Add missing
             gfc_init_se call in case ALLOCATE_PDT_COMP for scalar
             component default initializer.
fixerupper.patch (text/x-patch, 1.4 KB)
commit b55678bcc6c707f1069f1e702e0998ab1757ce00
Author: Christopher Albert <[email protected]>
Date:   Sun Feb 22 22:07:19 2026 +0100

    fortran: Initialize gfc_se in PDT component allocation [PR123949]
    
    Add missing gfc_init_se call for the default initializer case in
    ALLOCATE_PDT_COMP.  The adjacent KIND/LEN block (line 11118) and
    pdt_string block (line 11149) both initialize tse, but this block
    left it uninitialized, causing undefined behavior when tse.ss
    contained stack garbage.  Exposed as an ICE in gfc_conv_constant
    (trans-const.cc:425) on aarch64 with LTO bootstrap.
    
            PR fortran/123949
    
    gcc/fortran/ChangeLog:
    
            * trans-array.cc (structure_alloc_comps): Add missing
            gfc_init_se call in case ALLOCATE_PDT_COMP for scalar
            component default initializer.
    
    Signed-off-by: Christopher Albert <[email protected]>

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 6cddd80b8ae..e7666416213 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -11136,6 +11136,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tree dest,
 	    {
 	      gfc_se tse;
 	      gfc_expr *c_expr;
+	      gfc_init_se (&tse, NULL);
 	      c_expr = c->initializer;
 	      gfc_conv_expr_type (&tse, c_expr, TREE_TYPE (comp));
 	      gfc_add_block_to_block (&fnblock, &tse.pre);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.