https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64229
Bug ID: 64229 Summary: internal compiler error when assigning allocatable arrays of character(:) Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ondrej.certik at gmail dot com Created attachment 34223 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34223&action=edit Test program to trigger ICE The following code (also attached): $ cat test_ice.f90 program test_ice character(:), allocatable :: x(:), y(:) x = y end Produces an ICE: $ gfortran -v test_ice.f90 Driving: gfortran -v test_ice.f90 -l gfortran -l m -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/local/certik/bld/gcc/zzcagdji4y4w/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/local/certik/bld/gcc/zzcagdji4y4w --enable-checking=release --enable-languages=fortran,c,c++ --with-local-prefix=/local/certik/bld/gcc/zzcagdji4y4w --with-gmp=/local/certik/bld/gmp/vadkrj43wtyr --with-mpc=/local/certik/bld/mpc/sushaq7ufe2f --with-mpfr=/local/certik/bld/mpfr/vxwmnxjsshse --with-cloog=/local/certik/bld/cloog/f5p5vql5p36v --with-isl=/local/certik/bld/isl/qr4j7jaetze7 --enable-clocale=gnu --enable-__cxa_atexit --enable-shared --enable-threads=posix --disable-multilib --libdir=/local/certik/bld/gcc/zzcagdji4y4w/lib --with-stage1-ldflags='-L/local/certik/bld/cloog/f5p5vql5p36v/lib -Wl,-rpath=/local/certik/bld/cloog/f5p5vql5p36v/lib -L/local/certik/bld/gmp/vadkrj43wtyr/lib -Wl,-rpath=/local/certik/bld/gmp/vadkrj43wtyr/lib -L/local/certik/bld/isl/qr4j7jaetze7/lib -Wl,-rpath=/local/certik/bld/isl/qr4j7jaetze7/lib -L/local/certik/bld/mpc/sushaq7ufe2f/lib -Wl,-rpath=/local/certik/bld/mpc/sushaq7ufe2f/lib -L/local/certik/bld/mpfr/vxwmnxjsshse/lib -Wl,-rpath=/local/certik/bld/mpfr/vxwmnxjsshse/lib -L/local/certik/bld/patchelf/k3rloj265ogt/lib -Wl,-rpath=/local/certik/bld/patchelf/k3rloj265ogt/lib -L/local/certik/bld/zlib/3el5ccejre7b/lib -Wl,-rpath=/local/certik/bld/zlib/3el5ccejre7b/lib' --with-boot-ldflags='-L/local/certik/bld/cloog/f5p5vql5p36v/lib -Wl,-rpath=/local/certik/bld/cloog/f5p5vql5p36v/lib -L/local/certik/bld/gmp/vadkrj43wtyr/lib -Wl,-rpath=/local/certik/bld/gmp/vadkrj43wtyr/lib -L/local/certik/bld/isl/qr4j7jaetze7/lib -Wl,-rpath=/local/certik/bld/isl/qr4j7jaetze7/lib -L/local/certik/bld/mpc/sushaq7ufe2f/lib -Wl,-rpath=/local/certik/bld/mpc/sushaq7ufe2f/lib -L/local/certik/bld/mpfr/vxwmnxjsshse/lib -Wl,-rpath=/local/certik/bld/mpfr/vxwmnxjsshse/lib -L/local/certik/bld/patchelf/k3rloj265ogt/lib -Wl,-rpath=/local/certik/bld/patchelf/k3rloj265ogt/lib -L/local/certik/bld/zlib/3el5ccejre7b/lib -Wl,-rpath=/local/certik/bld/zlib/3el5ccejre7b/lib' Thread model: posix gcc version 4.9.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /local/certik/bld/gcc/zzcagdji4y4w/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/f951 test_ice.f90 -quiet -dumpbase test_ice.f90 -mtune=generic -march=x86-64 -auxbase test_ice -version -fintrinsic-modules-path /local/certik/bld/gcc/zzcagdji4y4w/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/finclude -o /tmp/ccQyibte.s GNU Fortran (GCC) version 4.9.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.9.2, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.9.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.9.2, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 test_ice.f90: In function ‘test_ice’: test_ice.f90:3:0: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:1741 x = y ^ 0x79b5dd gimplify_var_or_parm_decl ../.././gcc/gimplify.c:1741 0x79f9d7 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:8058 0x79d089 gimplify_modify_expr ../.././gcc/gimplify.c:4510 0x79f2c7 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:7627 0x7a0ce6 gimplify_stmt(tree_node**, gimple_statement_base**) ../.././gcc/gimplify.c:5373 0x79f793 gimplify_statement_list ../.././gcc/gimplify.c:1432 0x79f793 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:8042 0x7a0ce6 gimplify_stmt(tree_node**, gimple_statement_base**) ../.././gcc/gimplify.c:5373 0x7a157b gimplify_bind_expr ../.././gcc/gimplify.c:1099 0x79eaee gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:7824 0x7a0ce6 gimplify_stmt(tree_node**, gimple_statement_base**) ../.././gcc/gimplify.c:5373 0x79f793 gimplify_statement_list ../.././gcc/gimplify.c:1432 0x79f793 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:8042 0x7a0ce6 gimplify_stmt(tree_node**, gimple_statement_base**) ../.././gcc/gimplify.c:5373 0x7a157b gimplify_bind_expr ../.././gcc/gimplify.c:1099 0x79eaee gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../.././gcc/gimplify.c:7824 0x7a0ce6 gimplify_stmt(tree_node**, gimple_statement_base**) ../.././gcc/gimplify.c:5373 0x7a1b9a gimplify_body(tree_node*, bool) ../.././gcc/gimplify.c:8734 0x7a1e87 gimplify_function_tree(tree_node*) ../.././gcc/gimplify.c:8887 0x69caf7 cgraph_analyze_function(cgraph_node*) ../.././gcc/cgraphunit.c:648 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. This seems to be caused by the same bug as in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62142, because this compiles: $ gfortran -fno-realloc-lhs test_ice.f90 $ and gfortran 4.7.2 also compiles: $ gfortran test_ice.f90 $ So probably the fix in #62142 didn't fix all the cases. The above test case is the minimal example that still triggers the compiler error. The actual code where I discovered this problem is: type, extends(parameter_entry), public :: any_matrix private class(*), allocatable :: value(:,:) ... end subroutine get_matrix_character (this, value, errc) class(any_matrix), intent(in) :: this character(:), allocatable, intent(out) :: value(:,:) logical, intent(out) :: errc select type (v => this%value) type is (character(*)) value = v errc = .false. class default errc = .true. end select end subroutine It works with PGI and Intel.