public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58883] New: Segmentation fault when reshaping  a allocatable array to allocatable function
@ 2013-10-25 20:39 songtao.thu at gmail dot com
  2013-10-25 21:52 ` [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: songtao.thu at gmail dot com @ 2013-10-25 20:39 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-08 19:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-25 20:39 [Bug fortran/58883] New: Segmentation fault when reshaping a allocatable array to allocatable function songtao.thu at gmail dot com
2013-10-25 21:52 ` [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable burnus at gcc dot gnu.org
2014-07-06 17:05 ` dominiq at lps dot ens.fr
2014-07-07 20:01 ` pault at gcc dot gnu.org
2014-07-07 20:04 ` pault at gcc dot gnu.org
2014-07-08 19:51 ` pault at gcc dot gnu.org
2014-07-08 19:53 ` pault at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).