https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60576
--- Comment #44 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #43)
> The call of foo is translated to:
>
> {
> struct __class_MAIN___T_15_0t class.6;
> struct array15_t array.7;
>
> class.6._vptr = (struct __vtype_MAIN___T * {ref-all}) &__vtab_MAIN___T;
> class.6._data.data = (void *) x->data;
> class.6._data.offset = x->offset;
> class.6._data.dtype = x->dtype;
> class.6._data.dim[0 ...] = x->dim[0 ...];
> array.7 = *x;
> foo (&class.6);
> }
>
> Where's this funny array.7 coming from, and isn't it just a junk dereference?
This junk dereference is eliminated by:
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 3b9a9337984..7397f8b6ec5 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1024,12 +1024,14 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e,
gfc_symbol *fsym,
gfc_conv_array_parameter (parmse, e, false, fsym, proc_name, nullptr,
&lbshift, &packed);
+#if 0
if (derived_array && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE
(parmse->expr)))
{
*derived_array
= gfc_create_var (TREE_TYPE (parmse->expr), "array");
gfc_add_modify (&block, *derived_array, parmse->expr);
}
+#endif
if (optional)
{
I think it is also optimized as dead code.
And the sanitizer issue is not resolved... :-(