https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64555
Bug ID: 64555 Summary: Fail to compile array pointer to derived-type components Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: thfanning at gmail dot com When assigning an array pointer to a scalar component of an array of a derived type, compilation fails with undefined "span.n". Given the following code, test.f90: module mod_abc type a integer :: item end type type(a), pointer :: array(:) integer, pointer :: item(:) => NULL() contains subroutine init(n) integer :: n allocate(array(n)) item => array%item ! problem occurs here end subroutine end module program test use mod_abc integer, parameter :: n = 10 integer :: i print *, "Hello, World!" call init(n) do i = 1,n array(i)%item = i enddo do i = 1,n print "(i6,': ',i6)", i, item(i) enddo end program On an Intel architecture... gfortran -m32 test.f90: /var/folders/l9/qcd__g594cv5qn_nc1nwyvvrd6xjn9/T//ccmNxERg.s:209:non-relocatable subtraction expression, "_span.0" minus "L2$pb" /var/folders/l9/qcd__g594cv5qn_nc1nwyvvrd6xjn9/T//ccmNxERg.s:209:symbol: "_span.0" can't be undefined in a subtraction expression /var/folders/l9/qcd__g594cv5qn_nc1nwyvvrd6xjn9/T//ccmNxERg.s:93:non-relocatable subtraction expression, "_span.0" minus "L1$pb" /var/folders/l9/qcd__g594cv5qn_nc1nwyvvrd6xjn9/T//ccmNxERg.s:93:symbol: "_span.0" can't be undefined in a subtraction expression gfortran -m64 test.f90: Undefined symbols for architecture x86_64: "_span.0", referenced from: ___mod_abc_MOD_init in ccyXTbtG.o _MAIN__ in ccyXTbtG.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status On an embedded ARM architecture: gfortran test.f90: /tmp/cccNTntp.o: In function `__mod_abc_MOD_init': span.f90:(.text+0x1b4): undefined reference to `span.0' /tmp/cccNTntp.o: In function `MAIN__': span.f90:(.text+0x38c): undefined reference to `span.0' collect2: ld returned 1 exit status HOWEVER, if optimization is used on the ARM, then the code compiles correctly: gfortran -O test.f90 ./a.out Hello, World! 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10