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

            Bug ID: 113892
           Summary: Missing temporary in assignment for array-valued
                    function referencing host-associated array
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57402
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57402&action=edit
Testcase

The attached testcase is a slightly rewritten version of the discussion at:

https://fortran-lang.discourse.group/t/creating-temporary-array-when-declared-in-a-module/7379

All gfortran versions print:

          11          21          31
          12          22          32
          13          23          33

          11          12          13    T F F
          12          22          23    T T F
          13          23          33    T T T

Expected:

          11          21          31
          12          22          32
          13          23          33

          11          21          31    T T T
          12          22          32    T T T
          13          23          33    T T T

What happens?

Function create_matrix takes the host-associated array "am" and returns the
TRANSPOSE(am).  When assigning the result directly to "am" we get a wrong
result because no temporary is created.

Maybe the dependency analysis of assignments needs to take care of the
possibility that a non-elemental function might access a host-associated
(or USE-associated or COMMON) variable appearing on the lhs.

Reply via email to