https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66321
Bug ID: 66321 Summary: [4.9.2/5.1.0/6.0.0] errors allocating allocatable array component of pointer object component Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: damian at sourceryinstitute dot org Target Milestone: --- Possibly this bug is related to Bug 56471 (which is oustanding) and/or Bug 65841 (which has been fixed). The code listing below demonstrates what appears to be a rejection of valid code in gfortran versions 4.9.2, 5.1.0, and 6.0.0. After commenting the offending line, the resulting code generates a runtime segmentation fault when the subsequent line attempts automatically allocate the variable whose explicit source allocation was rejected in the original code. Both versions of the code compile and execute cleanly with the Cray, Portland Group, NAG, and Intel compilers. Damian localhost:seg-fault rouson$ cat compile-time-error.f90 type Bar integer, allocatable :: a(:) end type type Foo type (bar), pointer :: b end type type(Foo) f allocate(f%b) allocate(f%b%a,source=[3]) ! Compile-time error f%b%a = [3] ! Run-time seg fault end localhost:seg-fault rouson$ gfortran compile-time-error.f90 compile-time-error.f90:9:9: allocate(f%b%a,source=[3]) ! Compile-time error 1 Error: Array specification required in ALLOCATE statement at (1) localhost:seg-fault rouson$ sed 's/allocate(f%b%a/!allocate(f%b%a/' < compile-time-error.f90 > run-time-error.f90 localhost:seg-fault rouson$ gfortran run-time-error.f90 localhost:seg-fault rouson$ ./a.out Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10ad0ab26 #1 0x10ad0a0c3 #2 0x7fff8a317f19 #3 0x10ad03e5e #4 0x10ad03ea0 Segmentation fault: 11 localhost:seg-fault rouson$ gfortran --version GNU Fortran (MacPorts gcc6 6-20150510_0) 6.0.0 20150510 (experimental) Copyright (C) 2015 Free Software Foundation, Inc.