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

--- Comment #10 from anlauf at gcc dot gnu.org ---
(In reply to Kirill Chilikin from comment #9)
> This patch fixes it for me:
> 
> diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
> index 722ea933249..7b9bd279c01 100644
> --- a/gcc/fortran/trans-intrinsic.cc
> +++ b/gcc/fortran/trans-intrinsic.cc
> @@ -9864,7 +9864,11 @@ conv_isocbinding_function (gfc_se *se, gfc_expr *expr)
>        se->expr = gfc_evaluate_now (se->expr, &se->pre);
>      }
>    else if (expr->value.function.isym->id == GFC_ISYM_C_FUNLOC)
> -    gfc_conv_expr_reference (se, arg->expr);
> +    {
> +      gfc_conv_expr_reference (se, arg->expr);
> +      se->expr = convert (pvoid_type_node, se->expr);
> +      se->expr = gfc_evaluate_now (se->expr, &se->pre);
> +    }
>    else if (expr->value.function.isym->id == GFC_ISYM_C_ASSOCIATED)
>      {
>        gfc_se arg1se;
> 
> This code is simply copied from the block just above for C_LOC.

Yes, that seems to work.

The gfc_evaluate_now appears to be essential.  This might point to a
latent issue...

The tree dump also seems to suggest that the conversion to void* is necessary,
as otherwise the type of the temporary for the argument to set_funptr has an
unexpected type.

Anyway, no objections from my side.  Go ahead, and maybe add a suitable
comment that this code is needed.

Reply via email to