[Bug fortran/93918] Segfault with -Ofast when calling a routine with an array argument array(:)%component
mscfd at gmx dot net
gcc-bugzilla@gcc.gnu.org
Tue Feb 25 11:09:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93918
--- Comment #4 from martin <mscfd at gmx dot net> ---
After playing around a bit I am really confused about why and when array
temporaries are created.
The variant ppp_1 with a non-contiguous array pointer p works fine (with
-Ofast), but the variation ppp_2 (this time even with a contiguous array
pointer) fails. To make it even more puzzling, variation ppp_3, where the
pointer association is done in a function, works.
To me it seems obscure to understand and thus avoid creation of temporary
arrays.
program ppp_1
use mod
implicit none
integer :: n
integer, dimension(:,:), pointer :: a
integer, dimension(:), pointer :: p
n = 100000000
allocate(a(1:2,1:n), source=1)
p => a(1,1:n)
call foo(p, n)
deallocate(a)
end program ppp_1
program ppp_2
use mod
implicit none
type :: tt
integer :: u = 1
end type tt
type(tt), dimension(:), pointer :: r
integer :: n
integer, dimension(:), pointer :: p
n = 100000000
allocate(r(1:n))
p => r(:)%u
call foo(p, n)
deallocate(r)
end program ppp_2
program ppp_3
use mod
implicit none
type :: tt
integer :: u = 1
end type tt
type(tt), dimension(:), pointer :: r
integer :: n
integer, dimension(:), pointer :: p
n = 100000000
allocate(r(1:n))
p => get(r(1:n))
call foo(p, n)
deallocate(r)
contains
function get(x) result(q)
type(tt), dimension(:), target, intent(in) :: x
integer, dimension(:), pointer :: q
q => x(:)%u
end function get
end program ppp_3
More information about the Gcc-bugs
mailing list