http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53309

             Bug #: 53309
           Summary: Unnecessary temporary array creation in subroutine
                    call
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: towns...@astro.wisc.edu


Created attachment 27367
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27367
Example program

I'm encountering a situation where an unnecessary array is being created when
passing an assumed-shape dummy argument as the argument to a routine without an
explicit interface.

The attached example program illustrates the problem; when compiled with
-Warray-temporaries, I get the warning:

test_array_temp.f90:19.25:

    call sub_set_a(3, 3, a)
                         1
Warning: Creating array temporary at (1)

At compile time, there is no way of determining whether a is contiguous, and so
it would seem an array temporary is necessary. However, is it possible to do a
*runtime* check on whether a is contiguous, and if so avoid the copy? Intel
Fortran seems to manage this.

BTW, this issue arises when calling many of the LAPACK and BLAS routines from
Fortran 9x; it seems array temporaries are being created all over the place,
doubtless with a performance impact.

Reply via email to