Created attachment 1413643 [details] Reduced test case Trying to compile the attached source gives an internal gcc error $ gfortran -c -fcoarray=lib test.F90 test.F90:12:0: allocate(field0%data(M,N)) internal compiler error: in gfc_conv_descriptor_token, at fortran/trans-array.c:305 Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. The same code compiles if one changes "module test" to "program test".
$ rpm -q gcc gcc-gfortran gcc-7.3.1-5.fc27.x86_64 gcc-gfortran-7.3.1-5.fc27.x86_64
I'm able to reproduce this crash on the upstream "gcc-7-branch" using r258229. It's a read through NULL "field" in gfc_conv_descriptor_token: 298 gcc_assert (GFC_DESCRIPTOR_TYPE_P (type)); 299 gcc_assert (flag_coarray == GFC_FCOARRAY_LIB); 300 field = gfc_advance_chain (TYPE_FIELDS (type), CAF_TOKEN_FIELD); 301 302 /* Should be a restricted pointer - except in the finalization wrapper. */ 303 gcc_assert (field != NULL_TREE 304 && (TREE_TYPE (field) == prvoid_type_node 305 || TREE_TYPE (field) == pvoid_type_node)); 306 307 return fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field), where, on the gcc 7 branch, CAF_TOKEN_FIELD is 4. TYPE_FIELDS: (gdb) p type->type_non_common.values $2 = <field_decl 0x7ffff1a92e40 data> which has these chained fields: (gdb) p type->type_non_common.values->common.chain $3 = <field_decl 0x7ffff1a92ed8 offset> (gdb) p type->type_non_common.values->common.chain->common.chain $4 = <field_decl 0x7ffff1a9a000 dtype> (gdb) p type->type_non_common.values->common.chain->common.chain->common.chain $5 = <field_decl 0x7ffff1a9a2f8 dim> (gdb) p type->type_non_common.values->common.chain->common.chain->common.chain->common.chain $6 = <tree 0x0> i.e. we just have: "data", "offset", "dtype", "dim" so the 4th element is NULL. It's fixed on gcc-7-branch by r258233: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=78da60aad4588d8af4d3e91747964c35f5921b18 which, amonst other things made this guard less restrictive: diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 8c2c8a6..724c0fa 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1804,7 +1804,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) TREE_NO_WARNING (decl) = 1; } - if (flag_coarray == GFC_FCOARRAY_LIB && codimen) + if (flag_coarray == GFC_FCOARRAY_LIB) { decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("token"), leading to the "token" field being present in the chain, fixing the crash. The commit message has: PR fortran/83319 *trans-types.c (gfc_get_array_descriptor_base): Add the token field to the descriptor even when codimen not set. although that's not present in the gcc/fortran/ChangeLog The upstream bug would appear to be: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83319
Bug was fixed upstream: * on trunk (for gcc 8) on 2018-01-01 by r256065. * on gcc-7-branch on 2018-03-04 by r258233.
...and so will be fixed by gcc 7.4
As per Comment 3.
(In reply to Marek Polacek from comment #5) > As per Comment 3. But ... (In reply to Dave Malcolm from comment #4) > ...and so will be fixed by gcc 7.4 gcc 7.4 or the patch is not yet in Fedora 27, so the bug has not been fixed.
This message is a reminder that Fedora 27 is nearing its end of life. On 2018-Nov-30 Fedora will stop maintaining and issuing updates for Fedora 27. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '27'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 27 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.