https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64980
Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bernd.edlinger at hotmail dot
de
--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Mikael Morin from comment #5)
> (In reply to Mikael Morin from comment #4)
> > This cures it:
>
> Another way to cure it:
>
> Index: trans-expr.c
> ===================================================================
> --- trans-expr.c (révision 220514)
> +++ trans-expr.c (copie de travail)
> @@ -3783,10 +3783,6 @@ gfc_apply_interface_mapping_to_expr (gfc_interface
> expr->symtree = sym->new_sym;
> else if (sym->expr)
> gfc_replace_expr (expr, gfc_copy_expr (sym->expr));
> - /* Replace base type for polymorphic arguments. */
> - if (expr->ref && expr->ref->type == REF_COMPONENT
> - && sym->expr && sym->expr->ts.type == BT_CLASS)
> - expr->ref->u.c.sym = sym->expr->ts.u.derived;
> }
>
> /* ...and to subexpressions in expr->value. */
unfortunately this would make class_41.f03 fail.
class_41.f03 is very similar to this test case.
Both do deliberately pass a subclass to the base class,
just class_41.f03 uses identical pointer/allocatable attributes,
while this test case uses different pointer/allocatable attributes,
and this satisfies the condition in r218584.
However the intention of r214584 was to avoid aliasing
violations between class objects of the _same_ class type and different
pointer/allocatable attributes. Additionally to cause problems
(at least on ARM, but in theory on any target too...)
the class with the wrong attributes must be passed to a subroutine.
See PR60718 for details.
I see no aliasing problems in this example if we avoid to cast
the class type to the destination class type. And the value is
not passed to a subroutine.
So I would add the following to the condition that make the
new block only execute if both objects are of the same class.
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 220543)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -4539,6 +4539,8 @@
}
else if (e->ts.type == BT_CLASS && fsym
&& fsym->ts.type == BT_CLASS
+ && CLASS_DATA (fsym)->ts.u.derived
+ == CLASS_DATA (e)->ts.u.derived
&& !CLASS_DATA (fsym)->as
&& !CLASS_DATA (e)->as
&& (CLASS_DATA (fsym)->attr.class_pointer
With this patch all fortran test cases pass on x86_64.
And the ICE goes away in the reduced test example.
Does it work for you?