Re: [Patch, fortran] PR99250 - [F2018] coshape intrinsic is missing

Paul Richard Thomas <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <CAGkQGiKsn29euRMBw9hAe3cVzK-bW4ETKHB3kz40Vz2KRLBoEw@mail.gmail.com>
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?
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.