https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82121
Bug ID: 82121 Summary: Unclassifiable statement during compilation when assigning to a Character array in a derived type contained in a ASSOCIATE statement Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: iain.miller at ecmwf dot int Target Milestone: --- Created attachment 42136 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42136&action=edit Tarball of files showing issue and corresponding .s files A bug has been introduced in gfortran 7+ when trying to use an ASSOCIATE construct to associate a new variable name to a Character array held within a derived type. The correct F03 code was previously compiled without issue in gfortran 6.3.0 and earlier. Addressing the array verbosely without using the associate variable compiles. Addressing character arrays not in a derived type via an associate variable compiles as well. Output is: sucddh.F90:17:0: CADHTLS(2)='SVGTLT' Error: Unclassifiable statement at (1) Files to reproduce (also attached for completeness): #===== yomcddh.F90 =====# MODULE YOMCDDH IMPLICIT NONE SAVE TYPE :: TCDDH CHARACTER(len=12),ALLOCATABLE :: CADHTLS(:) END TYPE TCDDH CHARACTER(len=12),ALLOCATABLE :: CADHTTS(:) TYPE(TCDDH), POINTER :: YRCDDH => NULL() END MODULE YOMCDDH #===== end of yomcddh.F90 =====# #===== sucddh.F90 =====# SUBROUTINE SUCDDH() USE YOMCDDH , ONLY : YRCDDH,CADHTTS IMPLICIT NONE ALLOCATE (YRCDDH%CADHTLS(20)) ALLOCATE (CADHTTS(20)) ASSOCIATE(CADHTLS=>YRCDDH%CADHTLS, NORMCHAR=>CADHTTS) ! Direct reference to character array compiles correctly YRCDDH%CADHTLS(1)='SVGTLF' ! Reference to associated variable name fails to compile CADHTLS(2)='SVGTLT' NORMCHAR(1)='SVLTTC' END ASSOCIATE END SUBROUTINE SUCDDH #===== end of sucddh.F90 =====# Build using following commands: gfortran -c yomcddh.F90 gfortran -c -I. sucddh.F90 This has been confirmed on three separate x86_64 systems, two using SLES and gfortran 7.2.0 and one using Fedora and gfortran 7.1.1. Build details for SLES systems: lxg38: vsimple $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/home/group/usid/bin/compilers/lxg/gcc/7.2.0/libexec/gcc/x86_64-suse-linux/7.2.0/lto-wrapper Target: x86_64-suse-linux Configured with: ../gcc-7.2.0/configure --prefix=/home/group/usid/bin/compilers/lxg/gcc/7.2.0 --enable-languages=c,c++,objc,fortran,obj-c++ --enable-checking=release --enable-ssp --disable-libssp --disable-plugin --disable-libgcj --disable-libmudflap --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --with-cpu=generic --build=x86_64-suse-linux --enable-linker-build-id --enable-linux-futex --without-system-libunwind --disable-multilib --with-pkgversion='ECMWF build by usid' Thread model: posix gcc version 7.2.0 (ECMWF build by usid) Build details for Fedora system: Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC)