https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119986
kargls at comcast dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargls at comcast dot net
--- Comment #3 from kargls at comcast dot net ---
Additional data point. This gives the correct answer.
program main
integer j
complex, allocatable :: x(:)
x= [(cmplx(j,-j), j=1, 4)]
call fubar(x%re, x%im)
contains
subroutine fubar(u, v)
real, intent(in) :: u(:), v(:)
print *, 'phi%re:', u
print *, 'phi%im:', v
end subroutine
end program
% gfcx -o z a.f90 && ./z
phi%re: 1.00000000 2.00000000 3.00000000 4.0000000
phi%im: -1.00000000 -2.00000000 -3.00000000 -4.00000000
So, resolving the ultimate allocatable complex component seems to be involved.
Also note, that the above generates the expected temporary arrays.
% gfcx -o z -Warray-temporaries a.f90
a.f90:21:14:
21 | call fubar(x%re, x%im)
| 1
Warning: Creating array temporary at (1) [-Warray-temporaries]
a.f90:21:20:
21 | call fubar(x%re, x%im)
| 1
Warning: Creating array temporary at (1) [-Warray-temporaries]
Neil's original code does not generate temporaries and appears
to be passing the address of x(1)%phi%re.