[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 Richard Biener changed: What|Removed |Added Priority|P3 |P4 Target Milestone|--- |5.5
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 janus at gcc dot gnu.org changed: What|Removed |Added CC||pault at gcc dot gnu.org --- Comment #6 from janus at gcc dot gnu.org --- (In reply to Dominique d'Humieres from comment #5) > The ICE appeared between revisions r216305 (2014-10-16, compiles) and > r216470 (2014-10-20, ICE), likely r216427 (pr63553). Yes, that revision is certainly the culprit.
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 --- Comment #5 from Dominique d'Humieres --- The ICE appeared between revisions r216305 (2014-10-16, compiles) and r216470 (2014-10-20, ICE), likely r216427 (pr63553).
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 --- Comment #4 from janus at gcc dot gnu.org --- This patch seems to fix comment 3: Index: gcc/fortran/class.c === --- gcc/fortran/class.c (revision 243035) +++ gcc/fortran/class.c (working copy) @@ -208,6 +208,19 @@ gfc_add_component_ref (gfc_expr *e, const char *na gfc_component *c; gfc_ref **tail = &(e->ref); gfc_ref *ref, *next = NULL; + + if (e->expr_type == EXPR_ARRAY) +{ + /* Handle array constructors. */ + for (gfc_constructor *cons = gfc_constructor_first (e->value.constructor); + cons; cons = gfc_constructor_next (cons)) + { + if (cons->expr->ts.type == BT_CLASS) + gfc_add_component_ref (cons->expr, name); + } + return; +} + gfc_symbol *derived = e->symtree->n.sym->ts.u.derived; while (*tail != NULL) { but comment 0 still fails with a different ICE: internal compiler error: in fold_convert_loc, at fold-const.c:2361 0xb57cb1 fold_convert_loc(unsigned int, tree_node*, tree_node*) /home/jweil/gcc/gcc7/trunk/gcc/fold-const.c:2361 0x887d13 gfc_trans_array_ctor_element /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-array.c:1447 0x88853e gfc_trans_array_constructor_value /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-array.c:1631 0x88a538 trans_array_constructor /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-array.c:2365 0x88af3a gfc_add_loop_ss_code /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-array.c:2639 0x892042 gfc_conv_loop_setup(gfc_loopinfo*, locus*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-array.c:4890 0x8e63f2 gfc_trans_assignment_1 /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-expr.c:9781 0x8e7448 gfc_trans_assignment(gfc_expr*, gfc_expr*, bool, bool, bool, bool) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-expr.c:10124 0x8e74c0 gfc_trans_assign(gfc_code*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-expr.c:10136 0x882b1d trans_code /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans.c:1790 0x8830fe gfc_trans_code(gfc_code*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans.c:2097 0x8c127a gfc_generate_function_code(gfc_namespace*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans-decl.c:6271 0x883142 gfc_generate_code(gfc_namespace*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/trans.c:2114 0x811d07 translate_all_program_units /home/jweil/gcc/gcc7/trunk/gcc/fortran/parse.c:6038 0x81237c gfc_parse_file() /home/jweil/gcc/gcc7/trunk/gcc/fortran/parse.c:6238 0x86b55d gfc_be_parse_file /home/jweil/gcc/gcc7/trunk/gcc/fortran/f95-lang.c:202
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 --- Comment #3 from janus at gcc dot gnu.org --- Here is a slightly simpler version, replacing the function call with a variable reference, which fails with the same ICE with version 5, 6 and trunk: implicit none type foo end type type(foo) :: bar(1) class(foo), allocatable :: x allocate(x, source=foo()) bar = [x] end Version 4.9 again compiles fine, but I suspect that it generates wrong code.
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 --- Comment #2 from janus at gcc dot gnu.org --- Possibly related to PR 58557.
[Bug fortran/78641] [5/6/7 Regression] [OOP] ICE on polymorphic allocatable function in array constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78641 janus at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Known to work||4.9.4 Keywords||ice-on-valid-code Last reconfirmed||2016-12-02 CC||janus at gcc dot gnu.org Ever confirmed|0 |1 Summary|[OOP] ICE on polymorphic|[5/6/7 Regression] [OOP] |allocatable function in |ICE on polymorphic |array constructor |allocatable function in ||array constructor Known to fail||5.4.1, 6.2.0, 7.0 --- Comment #1 from janus at gcc dot gnu.org --- Version 4.9.4 swallows it without complaining, later versions give the ICE. The backtrace on trunk is: f951: internal compiler error: Segmentation fault 0xfd6d26 crash_signal /home/jweil/gcc/gcc7/trunk/gcc/toplev.c:333 0x7b2d75 gfc_add_component_ref(gfc_expr*, char const*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/class.c:211 0x87d5dd resolve_ordinary_assign /home/jweil/gcc/gcc7/trunk/gcc/fortran/resolve.c:10090 0x87f56d gfc_resolve_code(gfc_code*, gfc_namespace*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/resolve.c:10919 0x88c605 resolve_codes /home/jweil/gcc/gcc7/trunk/gcc/fortran/resolve.c:16028 0x88c752 gfc_resolve(gfc_namespace*) /home/jweil/gcc/gcc7/trunk/gcc/fortran/resolve.c:16063 0x85d10f resolve_all_program_units /home/jweil/gcc/gcc7/trunk/gcc/fortran/parse.c:5977 0x85d92b gfc_parse_file() /home/jweil/gcc/gcc7/trunk/gcc/fortran/parse.c:6224 0x8b6bc3 gfc_be_parse_file /home/jweil/gcc/gcc7/trunk/gcc/fortran/f95-lang.c:202