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

            Bug ID: 83927
           Summary: Type-Bound Procedure on element of Derived Type
                    PARAMETER Array
           Product: gcc
           Version: 7.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam at aphirst dot karoo.co.uk
  Target Milestone: ---

Created attachment 43173
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43173&action=edit
short program demonstrating the issue

I've tried to minimise the code sample as much as possible.
https://gist.github.com/aphirst/5028d3a0ec1c15011e2b1181e4f1a7b5

I have some arrays (one a variable, one a PARAMETER) of Type(MyType), and a
bound procedure %MyFunc() on that type.

Calls to that procedure using specific elements of that array, say
v(1)%MyFunc(), fail, complaining:

Error: Can't convert TYPE(mytype) to REAL(4) at (1)

However, if I replace those calls with identical ones to a parameter which is
scalar but otherwise identical (shown in the code in comments), it compiles and
runs just fine.

It strikes me as odd that a single element of an array works differently to a
scalar. The same array syntax DOES work when used on a variable array, and also
on a PARAMETER scalar, so the issue seems to be somehow related to the
combination of PARAMETER and array for the type-bound procedure logic.

I'm aware that there are other issues regarding PARAMETER arrays, including
#59298 which I reported quite a while ago.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59298

gcc version 7.2.1 20171224 (GCC), Arch Linux (x86_64)

If there's any further info which would be useful, please don't hesitate to
ask.

Reply via email to