https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93956
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |pault at gcc dot gnu.org, | |tkoenig at gcc dot gnu.org Last reconfirmed| |2020-04-14 Status|UNCONFIRMED |NEW --- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to martin from comment #0) > The following code (compiled without any options) prints "15000, 10000" for > the second call to foo, instead of the expected "20000, 10000". The first > call to foo gives the expected result. This is also reproducible with > gfortran-10 branch. > > This code is a variation of the one reported in bug 93918 to further > understand temporary array creation. > > program array_temps > implicit none > > type :: tt > integer :: u = 1 > integer :: v = 2 > end type tt > > type(tt), dimension(:), pointer :: r > integer :: n > integer, dimension(:), pointer :: p > > allocate(r(1:n)) This test case does not define n. Assuming you want to write n=10000 in there, I concur that the output should be as you describe. I assume that the span is not used correctly in the function. The test case works if you do p => r(:)%v instead of the call to get().