[Bug fortran/100551] [11/12 Regression] Passing return value of intrinsic to class(*) dummy argument can cause segfaults

anlauf at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 12 21:11:02 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100551

--- Comment #3 from anlauf at gcc dot gnu.org ---
Below fixes this PR and does not break the other testcase:

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index cce18d094a6..ebc9ea42beb 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5826,7 +5826,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                                     &derived_array);
        }
       else if (UNLIMITED_POLY (fsym) && e->ts.type != BT_CLASS
-              && gfc_expr_attr (e).flavor != FL_PROCEDURE)
+              && (gfc_expr_attr (e).flavor != FL_PROCEDURE
+                  || gfc_expr_attr (e).proc == PROC_INTRINSIC))
        {
          /* The intrinsic type needs to be converted to a temporary
             CLASS object for the unlimited polymorphic formal.  */

I would hope that Paul can explain why this works, or if this is the right
thing.


More information about the Gcc-bugs mailing list