Hi Harald,

The ICE is weird. I'll look in the morning. I take it, though, that
the supplied testcase works for you?

On reflection, given the nature of coarrays and that coshape does not
have a dim dummy, gfc_simplify_coshape is redundant and will be
removed.

Thanks for the quick feedback.

Paul

On Mon, 9 Feb 2026 at 22:06, Harald Anlauf <[email protected]> wrote:
>
> Hi Paul,
>
> Am 09.02.26 um 5:54 PM schrieb Paul Richard Thomas:
> > Hi All,
> >
> > This is a boilerplate implementation of the COSHAPE intrinsic. The
> > testcase is placed in the main gfortran.dg directory so that it can
> > make us of the option -fcoarry=lib to test the number of references to
> > _gfortran_caf_num_images (One to set no_images and to for the upper
> > bound of the last codimension).
> >
> > Regtests on FC43/x86_64. OK for mainline?
>
> this ICEs here for me with your patch applied and -fcoarray=lib:
>
> subroutine foo (a)
>    integer :: a[*]
>    print *, coshape (a,kind=2)
> end
>
>      3 |   print *, coshape (a,kind=2)
>        |                             1
> internal compiler error: in gfc_conv_ss_startstride, at
> fortran/trans-array.cc:5283
> 0x39f44ef internal_error(char const*, ...)
>          ../../gcc-trunk/gcc/diagnostic-global-context.cc:787
> 0x3a04a95 fancy_abort(char const*, int, char const*)
>          ../../gcc-trunk/gcc/diagnostics/context.cc:1812
> 0x112895c gfc_conv_ss_startstride(gfc_loopinfo*)
>          ../../gcc-trunk/gcc/fortran/trans-array.cc:5283
> 0x11d4d04 gfc_trans_transfer(gfc_code*)
>          ../../gcc-trunk/gcc/fortran/trans-io.cc:2718
> 0x11183f9 trans_code
>          ../../gcc-trunk/gcc/fortran/trans.cc:2584
> 0x1118574 gfc_trans_code_cond(gfc_code*, tree_node*)
>          ../../gcc-trunk/gcc/fortran/trans.cc:2716
> 0x11d3163 build_dt
>          ../../gcc-trunk/gcc/fortran/trans-io.cc:2061
> 0x11d323b gfc_trans_write(gfc_code*)
>          ../../gcc-trunk/gcc/fortran/trans-io.cc:2100
> 0x111836f trans_code
>          ../../gcc-trunk/gcc/fortran/trans.cc:2556
> 0x1118593 gfc_trans_code(gfc_code*)
>          ../../gcc-trunk/gcc/fortran/trans.cc:2724
> 0x116a1e0 gfc_generate_function_code(gfc_namespace*)
>          ../../gcc-trunk/gcc/fortran/trans-decl.cc:8225
> 0x11185d7 gfc_generate_code(gfc_namespace*)
>          ../../gcc-trunk/gcc/fortran/trans.cc:2741
> 0x1087ff9 translate_all_program_units
>          ../../gcc-trunk/gcc/fortran/parse.cc:7569
> 0x108897f gfc_parse_file()
>          ../../gcc-trunk/gcc/fortran/parse.cc:7899
> 0x10fcfe7 gfc_be_parse_file
>          ../../gcc-trunk/gcc/fortran/f95-lang.cc:247
>
> I also see a front-end memleak in gfc_simplify_coshape because
>
> +  /* Create the constructor for this array.  */
> +  for (d = 0; d < as->corank; d++)
> +       gfc_constructor_append_expr (&e->value.constructor,
> +                                shapes[d], &e->where);
> +  return e;
>
> appends the expressions shapes[d] to the ctor but does not
> free them.
>
> Can you have a look at both?
>
> Harald
>
> >
> > Paul
> >
> > PS Could somebody please check the intrinsic.texi entries?
>

Reply via email to