http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59450
Bug ID: 59450 Summary: ICE for Array Valued Function combined with Deferred Specification Function Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: b...@miller-mohr.de Hi, when I try to compile the code below I receive an internal compiler error. The idea of the test case is to have a base class with a type-bound procedure returning an array. The size of the array is determined by using a specification function with deferred binding, i.e. it will be implemented in a child class / extended derived type. When I use a component of the base class instead of the specification function the code compiles without problems. module classes implicit none type, abstract :: base_class integer :: varnum contains procedure(pvf_get_num), nopass, deferred :: get_num procedure :: get_array end type base_class abstract interface pure function pvf_get_num() result(num) integer :: num end function pvf_get_num end interface contains function get_array( this ) result(array) class(base_class), intent(in) :: this ! compiles ! integer, dimension( this%varnum ) :: array ! crashes integer, dimension( this%get_num() ) :: array array = 0 array(1) = 1 end function get_array end module classes In detail I obtain the following Driving: gfortran -v --save-temps gcc-test2.f90 -l gfortran -l m -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/lrz/mnt/sys.x86_64/compilers/gcc/4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8.2/configure --prefix=/lrz/sys/compilers/gcc/4.8.2 --enable-languages=ada,c,c++,fortran,java,go,objc,obj-c++ --with-mpfr=/lrz/sys/libraries/mpfr/3.0.0 --with-gmp=/lrz/sys/libraries/gmp/5.0.1 --with-mpc=/lrz/sys/libraries/mpc/0.9 Thread model: posix gcc version 4.8.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /lrz/mnt/sys.x86_64/compilers/gcc/4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/f951 gcc-test2.f90 -quiet -dumpbase gcc-test2.f90 -mtune=generic -march=x86-64 -auxbase gcc-test2 -version -fintrinsic-modules-path /lrz/mnt/sys.x86_64/compilers/gcc/4.8.2/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.2/finclude -o gcc-test2.s GNU Fortran (GCC) version 4.8.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.2, GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.8.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.2, GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 f951: internal compiler error: Segmentation fault 0x87f55f crash_signal ../../gcc-4.8.2/gcc/toplev.c:332 0x55971e mio_expr ../../gcc-4.8.2/gcc/fortran/module.c:3300 0x559d68 mio_array_spec ../../gcc-4.8.2/gcc/fortran/module.c:2406 0x559e8f mio_component ../../gcc-4.8.2/gcc/fortran/module.c:2596 0x55a11a mio_component_list ../../gcc-4.8.2/gcc/fortran/module.c:2624 0x55a11a mio_symbol ../../gcc-4.8.2/gcc/fortran/module.c:3816 0x55a442 write_symbol ../../gcc-4.8.2/gcc/fortran/module.c:5090 0x55a58d write_symbol0 ../../gcc-4.8.2/gcc/fortran/module.c:5130 0x55a535 write_symbol0 ../../gcc-4.8.2/gcc/fortran/module.c:5109 0x55a535 write_symbol0 ../../gcc-4.8.2/gcc/fortran/module.c:5109 0x55a535 write_symbol0 ../../gcc-4.8.2/gcc/fortran/module.c:5109 0x55caa7 write_module ../../gcc-4.8.2/gcc/fortran/module.c:5396 0x55caa7 gfc_dump_module(char const*, int) ../../gcc-4.8.2/gcc/fortran/module.c:5534 0x56844a gfc_parse_file() ../../gcc-4.8.2/gcc/fortran/parse.c:4623 0x5a3c05 gfc_be_parse_file ../../gcc-4.8.2/gcc/fortran/f95-lang.c:189 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Compiling the same source with 4.7.1 (on another system) I do not receive an ICE, but instead get error reports that the specification functions wouldn't be pure Using built-in specs. COLLECT_GCC=gfortran-4.7.1 Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix /home/SOFTWARE/GCC/gcc-4.7.1 --program-suffix=-4.7.1 --enable-version-specific-runtime-libs --enable-languages=c,c++,fortran Thread model: posix gcc version 4.7.1 (GCC) COLLECT_GCC_OPTIONS='-v' '-c' '-save-temps' '-mtune=generic' '-march=x86-64' /home/SOFTWARE/GCC/gcc-4.7.1/libexec/gcc/x86_64-unknown-linux-gnu/4.7.1/f951 gcc-test2.f90 -quiet -dumpbase gcc-test2.f90 -mtune=generic -march=x86-64 -auxbase gcc-test2 -version -fintrinsic-modules-path /home/SOFTWARE/GCC/gcc-4.7.1/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/finclude -o gcc-test2.s GNU Fortran (GCC) version 4.7.1 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.1, GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.7.1 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.1, GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE gcc-test2.f90:27.23: integer, dimension( this%get_num() ) :: array 1 Error: Function 'this' at (1) must be PURE Tanks in advance Marcus