public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/64578] New: Seg-fault and ICE with unlimited polymorphic array pointer function
@ 2015-01-13  1:18 damian at sourceryinstitute dot org
  2015-01-13  1:23 ` [Bug fortran/64578] " damian at sourceryinstitute dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: damian at sourceryinstitute dot org @ 2015-01-13  1:18 UTC (permalink / raw)
  To: gcc-bugs

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)


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

end of thread, other threads:[~2015-01-18 22:02 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13  1:18 [Bug fortran/64578] New: Seg-fault and ICE with unlimited polymorphic array pointer function damian at sourceryinstitute dot org
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

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