http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56218
Bug #: 56218 Summary: Segfault with allocatable intent(out) derived type argument having allocatable component Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: towns...@astro.wisc.edu When using a subroutine with an allocatable intent(out) argument which is a derived type, and this derived type itself contains an allocatable argument, a segfault occurs on subroutine entry. The segfault disappears if the argument is declared intent(inout). Example code (compiled with gfortran 4.8.0 20121215 on OS X 10.7.5): -- program test_poly implicit none type :: foo_t real, allocatable :: a(:) end type foo_t class(foo_t), allocatable :: f call do_stuff(f) contains subroutine do_stuff (f) class(foo_t), intent(out), allocatable :: f allocate(f) allocate(f%a(3)) f%a = [1.,2.,3.] end subroutine do_stuff end program test_poly -- Output from gdb: -- (gdb) run Starting program: /Users/townsend/test_poly Reading symbols for shared libraries ++++........................ done Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 0x00000001000015dd in do_stuff (f=Invalid F77 type code 3 in symbol table. ) at test_poly.f90:15 15 subroutine do_stuff (f) (gdb) --