This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/58883] New: Segmentation fault when reshaping a allocatable array to allocatable function
- From: "songtao.thu at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 25 Oct 2013 20:39:42 +0000
- Subject: [Bug fortran/58883] New: Segmentation fault when reshaping a allocatable array to allocatable function
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883
Bug ID: 58883
Summary: Segmentation fault when reshaping a allocatable array
to allocatable function
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: songtao.thu at gmail dot com
When I reshape a allocatable array to allocatable function output, segmentation
fault appears.
Test Case1:
program main
implicit none
print *, foo()
contains
function foo()
integer, allocatable :: foo(:,:)
integer, allocatable :: temp(:)
temp = [1,2,3,4,5,6,7,8]
foo = reshape(temp,[2,4])
end function
end program
However, test case2 works fine:
program main
implicit none
print *, foo()
contains
function foo()
integer, allocatable :: foo(:,:)
integer, allocatable :: temp(:), temp2(:,:)
temp = [1,2,3,4,5,6,7,8]
temp2 = reshape(temp,[2,4])
foo = temp2 ! or call move_alloc(temp2,foo)
end function
end program
Hopefully someone can figure it out.
Tao Song