https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62242
Bug ID: 62242 Summary: ICE with character function in expression Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jwmwalrus at gmail dot com Hi, When trying to compile the following code: module gfbug implicit none save contains pure function UpperCase(string) result(upper) character(*), intent(IN) :: string character(LEN(string)) :: upper integer :: i, j upper = string do i = 1, LEN_TRIM(upper) j = IACHAR(upper(i:i)) select case (j) case (97:122) upper(i:i) = ACHAR(j - 32) case default end select enddo end function pure function isNotElementOf(scalar, array) result(status) logical :: status character(*), intent(IN) :: scalar, array(:) integer :: i status = .NOT. ANY(UpperCase(scalar) == [(UpperCase(array(i)), & i = 1, SIZE(array))]) end function end module gfbug I get the following output: $ /usr/lib/gcc-snapshot/bin/gfortran -c ./gfbug.f90 ./gfbug.f90: In function 'uppercase': ./gfbug.f90:10:0: internal compiler error: in expand_expr_real_1, at expr.c:9492 upper = string ^ Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-snapshot/README.Bugs> for instructions. The UpperCase function is not really the issue, but its usage within the isNotElementOf function. Removing the PURE attribute does not affect the outcome. The ifort and sunf95 compilers handle the code just fine. Tested with both gfortran 4.9 and the 20140814 GCC snapshot: $ lsb_release -rd Description: Debian GNU/Linux testing (jessie) Release: testing $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.1-4' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.9.1 (Debian 4.9.1-4) $ /usr/lib/gcc-snapshot/bin/gfortran -v Using built-in specs. COLLECT_GCC=/usr/lib/gcc-snapshot/bin/gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.10.0/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 20140814-1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++ --prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.10-snap-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.10-snap-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.10-snap-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --disable-werror --enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.10.0 20140814 (experimental) [trunk revision 213954] (Debian 20140814-1)