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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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 ` burnus at gcc dot gnu.org
  2014-07-06 17:05 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-10-25 21:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-25
                 CC|                            |burnus at gcc dot gnu.org
            Summary|Segmentation fault when     |Wrong code with realloc on
                   |reshaping  a allocatable    |assignment with assigning
                   |array to allocatable        |RESHAPE() to the function
                   |function                    |result variable
     Ever confirmed|0                           |1
      Known to fail|                            |4.8.1, 4.9.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Confirmed.


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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-06 17:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
AFAICT this PR is fixed by the patch for pr61459.


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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-07 20:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Mon Jul  7 20:00:49 2014
New Revision: 212338

URL: https://gcc.gnu.org/viewcvs?rev=212338&root=gcc&view=rev
Log:
2014-07-07  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * trans-expr.c (fcncall_realloc_result): Use the natural type
    for the address expression of 'res_desc'.

2014-07-07  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * gfortran.dg/allocatable_function_8.f90 : New test

Added:
   
branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/allocatable_function_8.f90
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-07 20:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Mon Jul  7 20:04:05 2014
New Revision: 212339

URL: https://gcc.gnu.org/viewcvs?rev=212339&root=gcc&view=rev
Log:
2014-07-07  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * trans-expr.c (fcncall_realloc_result): Use the natural type
    for the address expression of 'res_desc'.

2014-07-07  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * gfortran.dg/allocatable_function_8.f90 : New test

Added:
    trunk/gcc/testsuite/gfortran.dg/allocatable_function_8.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-08 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Tue Jul  8 19:51:04 2014
New Revision: 212369

URL: https://gcc.gnu.org/viewcvs?rev=212369&root=gcc&view=rev
Log:
2014-07-08  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * trans-expr.c (fcncall_realloc_result): Use the natural type
    for the address expression of 'res_desc'.

2014-07-08  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/61459
    PR fortran/58883
    * gfortran.dg/allocatable_function_8.f90 : New test

Added:
   
branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/allocatable_function_8.f90
Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/58883] Wrong code with realloc on assignment with assigning RESHAPE() to the function result variable
  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
                   ` (4 preceding siblings ...)
  2014-07-08 19:51 ` pault at gcc dot gnu.org
@ 2014-07-08 19:53 ` pault at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2014-07-08 19:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58883

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |pault at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on 4.8, 4.9 and trunk.

Thanks for the report

Paul


^ 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).