The current 8.0 trunk gives an ICE on the following example. 6.4.1 also gives an ICE. type foo integer n end type type bar type(foo) array(2) end type type(bar) b associate (n_array => b%array%n) select case (n_array(1)) case default end select end associate end Here's the traceback $ gfortran -c gfortran-20171124.f90 gfortran-20171124.f90:9:0: select case (n_array(1)) internal compiler error: in gfc_get_element_type, at fortran/trans-types.c:1231 0x5a5da8 gfc_get_element_type(tree_node*) ../../gcc/fortran/trans-types.c:1231 0x95d247 trans_associate_var ../../gcc/fortran/trans-stmt.c:1632 0x95d247 gfc_trans_block_construct(gfc_code*) ../../gcc/fortran/trans-stmt.c:1890 0x8e48c7 trans_code ../../gcc/fortran/trans.c:1924 0x90e7a8 gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6437 0x89d036 translate_all_program_units ../../gcc/fortran/parse.c:6091 0x89d036 gfc_parse_file() ../../gcc/fortran/parse.c:6294 0x8e0eaf gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
I thought that assigning the select case expression to a temporary integer and using that variable in the select case statement would be a workaround, but no. You can put anything unrelated to the associate name in the select case and you still get an ICE. It seems the the associate block itself is the problem. Here's the tweaked example type foo integer n end type type bar type(foo) array(2) end type type(bar) b integer :: m=0 associate (n_array => b%array%n) select case (m) case default end select end associate end
Turns out you don't need anything at all in the associate block to get an ICE: type foo integer n end type type bar type(foo) array(2) end type type(bar) b associate (n_array => b%array%n) end associate end
Regression occurring between revisions r205210 (2013-11-21, OK) and r207996 (2014-02-21, ICE).
AFAICT this seems fixed by a recent patch, likely r260414 for pr49636.
Author: pault Date: Sun Oct 14 09:25:13 2018 New Revision: 265148 URL: https://gcc.gnu.org/viewcvs?rev=265148&root=gcc&view=rev Log: 2018-10-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/83146 * gfortran.dg/associate_43.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/associate_43.f90 Modified: trunk/gcc/testsuite/ChangeLog
Indeed, Dominique this has been fixed. I have added a testcase to trunk to make sure that it remains nailed to the floor. I do not think that this is necessary for 8-branch. Thanks for the report. Paul