public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "damian at sourceryinstitute dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/64578] New: Seg-fault and ICE with unlimited polymorphic array pointer function
Date: Tue, 13 Jan 2015 01:18:00 -0000	[thread overview]
Message-ID: <bug-64578-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 64578
           Summary: Seg-fault and ICE with unlimited polymorphic array
                    pointer function
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org

The code below seg faults with a gfortran 5.0 build dated 20141222 and
generates an internal compiler error when the print statement is uncommented. 
The same code compiles, executes without error, and the print statement prints
"T" with the Cray compiler.  Similar code also compiles and executes cleanly
with the Intel and NAG compilers, although I didn't test this exact (reduced)
case with Intel and NAG.

Damian


$cat unlim-poly-array-ptr-func.f90 
  type foo 
     real, allocatable :: component(:)
  end type 
  type (foo), target :: f
  class(*), pointer :: ptr(:)
  allocate(f%component(1),source=[0.])
  call associate_pointer(f,ptr)
  ptr => return_pointer(f)  ! runtime segmentation fault
 !print *,associated(return_pointer(f)) ! ICE 
contains
  subroutine associate_pointer(this, item)
    class(foo), target :: this
    class(*), pointer :: item(:)
    item => this%component
  end subroutine 
  function return_pointer(this) 
    class(foo), target :: this
    class(*), pointer :: return_pointer(:)
    return_pointer => this%component
  end function 
end
$gfortran unlim-poly-array-ptr-func.f90 
$./a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7FA26BE8EBB7
#1  0x7FA26BE8DDB0
#2  0x7FA26B39949F
#3  0x400F55 in return_pointer.3443 at unlim-poly-array-ptr-func.f90:0
#4  0x400A46 in MAIN__ at unlim-poly-array-ptr-func.f90:0
Segmentation fault (core dumped)
$gfortran --version | head -1
GNU Fortran (GCC) 5.0.0 20141222 (experimental)


             reply	other threads:[~2015-01-13  1:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13  1:18 damian at sourceryinstitute dot org [this message]
2015-01-13  1:23 ` [Bug fortran/64578] " damian at sourceryinstitute dot org
2015-01-13  1:25 ` damian at sourceryinstitute dot org
2015-01-13  8:42 ` [Bug fortran/64578] [OOP] " janus at gcc dot gnu.org
2015-01-13  8:43 ` janus at gcc dot gnu.org
2015-01-13 10:36 ` dominiq at lps dot ens.fr
2015-01-13 10:53 ` janus at gcc dot gnu.org
2015-01-13 13:45 ` janus at gcc dot gnu.org
2015-01-14 20:40 ` paul.richard.thomas at gmail dot com
2015-01-15  9:23 ` pault at gcc dot gnu.org
2015-01-16 23:06 ` paul.richard.thomas at gmail dot com
2015-01-17 20:44 ` pault at gcc dot gnu.org
2015-01-17 21:34 ` dominiq at lps dot ens.fr
2015-01-18 15:53 ` pault at gcc dot gnu.org
2015-01-18 16:07 ` paul.richard.thomas at gmail dot com
2015-01-18 18:50 ` paul.richard.thomas at gmail dot com
2015-01-18 22:02 ` pault at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64578-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).