Maybe this could be handled by the Middle End, once the array operations in the ME are implemented. This would save us from checking the alias information in the FE. Regarding the "Middle-End Array Expressions", see: http://www.gccsummit.org/2008/gcc-2008-proceedings.pdf, pp. 33-42. * * * From: http://gcc.gnu.org/ml/fortran/2008-07/msg00166.html PS The example from Daniel, SUBROUTINE sub(I) REAL, PARAMETER :: PI = 3.1415 REAL, DIMENSION(:), POINTER :: I I = 2.0 * PI**2 * I END SUBROUTINE produces a temporary because the scalarizer makes no attempt to resolve pointers, for obvious reasons. We could add a check that the only pointer on the rhs is the same as that on the lhs, with no dependencies, and that there are no targets in the rhs expression.
Tobias, thanks for opening the PR.
See also PR36842 which would benefit as well.
See also PR 36928 (interleaved assignment, where also an unneeded temporary is created).
Confirmed.
This seemingly was fixed a while ago; -Warray-temporaries does not warn for 4.4.3, 4.5.1 nor current trunk. Relevant section of the dump is: while (1) { if (S.0 > D.1515) goto L.1; (*D.1516)[(S.0 + D.1520) * D.1523 + D.1517] = (*D.1512)[S.0 * D.1522 + D.1513] * 1.973804473876953125e+1; S.0 = S.0 + 1; } Closing as fixed.