]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Initialize gfc_se in PDT component allocation [PR123949]
authorChristopher Albert <albert@tugraz.at>
Sun, 22 Feb 2026 21:07:19 +0000 (22:07 +0100)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 23 Feb 2026 04:35:26 +0000 (20:35 -0800)
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 <albert@tugraz.at>
gcc/fortran/trans-array.cc

index 6cddd80b8ae89f7ef3115a5dd748020e26a40ed0..e7666416213895f6235568c72e49782c34e2c437 100644 (file)
@@ -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);