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

--- Comment #5 from Andrew Benson <abensonca at gcc dot gnu.org> ---
With apologies for the long delay in replying - thanks for pointing out that I
had the result of a constructor undefined. In this updated example I think that
constructor results are now correctly defined, but the segfault still occurs:

module bugMod

  type :: rm
     integer :: c=0
   contains
     procedure :: rma
     generic   :: assignment(=) => rma
  end type rm

  type :: lc
     type(rm) :: lm
  end type lc

contains

  subroutine rma(to,from)
    implicit none
    class(rm), intent(  out) :: to
    class(rm), intent(in   ) :: from

    return
  end subroutine rma

end module bugMod

program bug
  use bugMod
  implicit none
  type(lc), pointer :: i

  allocate(i)
  i=lc(rm())
end program bug


Compiling this with current trunk results in:

> ./a.out 

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

Backtrace for this error:
#0  0x7f73ba23e6ef in ???
#1  0x401299 in bug
        at /home/abenson/bug.F90:32
#2  0x401310 in main
        at /home/abenson/bug.F90:27
Segmentation fault (core dumped)



Changing

  type(lc), pointer :: i

to 

    type(lc), allocatable :: i

or removing the defined assignment makes the segfault go away.

For what it's worth, ifort compiles and runs this without any issue.

Reply via email to