Changed between 20171217 and 20180107 : $ cat z1.f90 subroutine s(x) character(*) :: x associate (y => x) end associate end $ gfortran-8-20171217 -c z1.f90 $ $ gfortran-8-20180121 -c z1.f90 during RTL pass: expand z1.f90:1:0: subroutine s(x) internal compiler error: in set_parm_default_def_partition, at tree-ssa-coalesce.c:1919 0xc72efc set_parm_default_def_partition ../../gcc/tree-ssa-coalesce.c:1919 0xc72e07 for_all_parms ../../gcc/tree-ssa-coalesce.c:1023 0xc74798 get_parm_default_def_partitions(_var_map*) ../../gcc/tree-ssa-coalesce.c:1936 0xc2099b remove_ssa_form ../../gcc/tree-outof-ssa.c:971 0xc2099b rewrite_out_of_ssa(ssaexpand*) ../../gcc/tree-outof-ssa.c:1174 0x805810 execute ../../gcc/cfgexpand.c:6218
Configured with --enable-checking=yes : $ gfortran-8-20180121-chk -c z1.f90 z1.f90:1:0: subroutine s(x) internal compiler error: tree check: expected parm_decl, have var_decl in assign_parm_find_data_types, at function.c:2456 0x61e2e1 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/tree.c:9337 0x9e9224 tree_check(tree_node*, char const*, int, char const*, tree_code) ../../gcc/tree.h:3132 0x9e9224 assign_parm_find_data_types ../../gcc/function.c:2456 0x9ef55b gimplify_parameters(gimple**) ../../gcc/function.c:4014 0xa5eccc gimplify_body(tree_node*, bool) ../../gcc/gimplify.c:12631 0xa5f084 gimplify_function_tree(tree_node*) ../../gcc/gimplify.c:12800 0x8aed87 cgraph_node::analyze() ../../gcc/cgraphunit.c:670 0x8b2483 analyze_functions ../../gcc/cgraphunit.c:1131 0x8b2f92 symbol_table::finalize_compilation_unit() ../../gcc/cgraphunit.c:2691
Confirmed. Seems to have started with r256021.
> Seems to have started with r256021. I reached the same conclusion.
Somehow the VAR_DECL for 'y' is in the PARM_DECL chain for the FUNCTION_DECL s: <function_decl 0x7ffff6a52f00 s type <function_type 0x7ffff6a53f18 type <void_type 0x7ffff68a8f18 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff68a8f18 pointer_to_this <pointer_type 0x7ffff68af0a8>> QI size <integer_cst 0x7ffff6894cd8 constant 8> unit-size <integer_cst 0x7ffff6894cf0 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff6a53e70 attributes <tree_list 0x7ffff6a55578 purpose <identifier_node 0x7ffff6900d48 fn spec> value <tree_list 0x7ffff6a55550 value <string_cst 0x7ffff6a48900 constant ".w">>> arg-types <tree_list 0x7ffff6a55528 value <reference_type 0x7ffff6a53dc8> chain <tree_list 0x7ffff6a55500 value <integer_type 0x7ffff68a8738 integer(kind=8)> chain <tree_list 0x7ffff68a7aa0 value <void_type 0x7ffff68a8f18 void>>>>> public static QI t.f90:1:0 align:8 warn_if_not_align:0 context <translation_unit_decl 0x7ffff689e168 t.f90> initial <block 0x7ffff6a58060> result <result_decl 0x7ffff689e1e0 D.3758 type <void_type 0x7ffff68a8f18 void> ignored VOID t.f90:1:0 align:8 warn_if_not_align:0 context <function_decl 0x7ffff6a52f00 s>> (mem:QI (symbol_ref:DI ("s_") [flags 0x3] <function_decl 0x7ffff6a52f00 s>) [0 S1 A8]) arguments <parm_decl 0x7ffff6a41280 x type <reference_type 0x7ffff6a531f8 type <array_type 0x7ffff6a530a8> unsigned restrict DI size <integer_cst 0x7ffff6894be8 constant 64> unit-size <integer_cst 0x7ffff6894c00 constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality> readonly used unsigned DI passed-by-reference t.f90:1:0 size <integer_cst 0x7ffff6894be8 64> unit-size <integer_cst 0x7ffff6894c00 8> align:64 warn_if_not_align:0 context <function_decl 0x7ffff6a52f00 s> arg-type <reference_type 0x7ffff6a53dc8 type <array_type 0x7ffff6a53c78> unsigned restrict DI size <integer_cst 0x7ffff6894be8 64> unit-size <integer_cst 0x7ffff6894c00 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff6a53dc8> chain <parm_decl 0x7ffff6a41200 _x type <integer_type 0x7ffff68a8738 integer(kind=8)> readonly used DI t.f90:1:0 size <integer_cst 0x7ffff6894be8 64> unit-size <integer_cst 0x7ffff6894c00 8> align:64 warn_if_not_align:0 context <function_decl 0x7ffff6a52f00 s> arg-type <integer_type 0x7ffff68a8738 integer(kind=8)> chain <var_decl 0x7ffff7fefab0 y>>>
I have a "fix", I'll post it shortly.
Patch: https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01917.html
Some additional testcases : $ cat z2.f90 subroutine s(x) character(*) :: x associate (y => [x]) print *, size(y), len(y), y end associate end $ cat z3.f90 subroutine s(x) character(*) :: x associate (y => [x, x]) print *, y end associate end $ cat z4.f90 subroutine s(x) character(*) :: x associate (y => x) y = 'abc' print *, y end associate end $ cat z5.f90 subroutine s(x) character(*) :: x associate (y => x//x) print *, y end associate end
Author: jb Date: Thu Feb 1 19:47:15 2018 New Revision: 257310 URL: https://gcc.gnu.org/viewcvs?rev=257310&root=gcc&view=rev Log: PR 83975 Associate target with non-constant character length When associating a variable of type character, if the length of the target isn't known at compile time, generate an error. See PR 83344 for more details. Regtested on x86_64-pc-linux-gnu. gcc/fortran/ChangeLog: 2018-02-01 Janne Blomqvist <jb@gcc.gnu.org> PR 83975 PR 83344 * resolve.c (resolve_assoc_var): Generate an error if target length unknown. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c
Author: pault Date: Mon Feb 19 22:09:13 2018 New Revision: 257827 URL: https://gcc.gnu.org/viewcvs?rev=257827&root=gcc&view=rev Log: 2018-02-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/83344 PR fortran/83975 * resolve.c (resolve_assoc_var): Rearrange the logic for the determination of the character length of associate names. If the associate name is missing a length expression or the length expression is not a constant and the target is not a variable, make the associate name allocatable and deferred length. * trans-decl.c (gfc_get_symbol_decl): Null the character length backend_decl for deferred length associate names that are not variables. Set 'length' to gfc_index_zero_node for character associate names, whose character length is a PARM_DECL. 2018-02-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/83344 PR fortran/83975 * gfortran.dg/associate_22.f90: Enable commented out test. * gfortran.dg/associate_36.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/associate_36.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/associate_22.f90
AFAICT Paul Thomas nailed this in r257827, closing as fixed.