https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122002
--- Comment #8 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #6)
> 'name' is never initialized:
>
> /* Used to build up the name of the PDT instance. The prefix uses 4
> characters and each KIND parameter 2 more. Allow 8 of the latter. */
> char name[GFC_MAX_SYMBOL_LEN + 21];
>
> Can one try setting
>
> name[0] = ’\0’;
>
> or similar?
This was just fishing in the dark.
The following fixes the uninitialized reads here for pdt_13.f03:
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 99644939056..a10cc754b36 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -3857,7 +3881,7 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list,
gfc_symbol **sym,
/* The symbol for the parameter in the template f2k_namespace. */
gfc_symbol *param;
/* The hoped for instance of the PDT. */
- gfc_symbol *instance;
+ gfc_symbol *instance = NULL;
/* The list of parameters appearing in the PDT declaration. */
gfc_formal_arglist *type_param_name_list;
/* Used to store the parameter specification list during recursive calls.
*/
@@ -4037,6 +4061,7 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list,
gfc_symbol **sym,
goto error_return;
}
+ kind_value = 0;
gfc_extract_int (kind_expr, &kind_value);
sprintf (name + strlen (name), "_%d", kind_value);
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 638018bcce3..68413ec55da 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -4067,7 +4068,7 @@ gfc_match_rvalue (gfc_expr **result)
{
gfc_symtree *pdt_st;
gfc_symbol *pdt_sym;
- gfc_actual_arglist *ctr_arglist, *tmp;
+ gfc_actual_arglist *ctr_arglist = NULL, *tmp;
gfc_component *c;
/* Obtain the template. */