Affects versions down to at least 4.8 : $ cat z1.f90 subroutine s(*) bind(c) end $ gfortran-9-20180513 -c z1.f90 f951: internal compiler error: Segmentation fault 0xb9f4bf crash_signal ../../gcc/toplev.c:325 0x71bbfd resolve_fl_procedure ../../gcc/fortran/resolve.c:12504 0x71bbfd resolve_symbol ../../gcc/fortran/resolve.c:15157 0x73639b do_traverse_symtree ../../gcc/fortran/symbol.c:4149 0x71cb1a resolve_types ../../gcc/fortran/resolve.c:16456 0x71839c gfc_resolve(gfc_namespace*) ../../gcc/fortran/resolve.c:16570 0x701b6a resolve_all_program_units ../../gcc/fortran/parse.c:6060 0x701b6a gfc_parse_file() ../../gcc/fortran/parse.c:6310 0x748adf gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
Paul, The ICE can be fixed by checking for a NULL pointer. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 260235) +++ gcc/fortran/resolve.c (working copy) @@ -12501,7 +12501,7 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) while (curr_arg != NULL) { /* Skip implicitly typed dummy args here. */ - if (curr_arg->sym->attr.implicit_type == 0) + if (curr_arg->sym && curr_arg->sym->attr.implicit_type == 0) if (!gfc_verify_c_interop_param (curr_arg->sym)) /* If something is found to fail, record the fact so we can mark the symbol for the procedure as not being HOwever, I think we then have an accepts invalid as an alternate return takes a label. If I look at gfc_match_formal_arglist in decl.c, it looks like your PDT work may have touched the area that should issue an error. 81764 dnovillo if (gfc_match_char ('*') == MATCH_YES) 197389 janus { 197389 janus sym = NULL; 255311 pault if (!typeparam && !gfc_notify_std (GFC_STD_F95_OBS, 255311 pault "Alternate-return argument at %C")) 197389 janus { 197389 janus m = MATCH_ERROR; 197389 janus goto cleanup; 197389 janus } 255311 pault else if (typeparam) 255311 pault gfc_error_now ("A parameter name is required at %C"); 197389 janus } Do you have any insights?
(In reply to kargl from comment #1) > HOwever, I think we then have an accepts invalid as an alternate > return takes a label. Whoops, I may have misread the standard. The label applies to the actual argument. A dummy argument of '*' alone signifies an alternate return, the patch in #1 indeed fixes the issue.
Author: kargl Date: Thu May 24 23:28:35 2018 New Revision: 260698 URL: https://gcc.gnu.org/viewcvs?rev=260698&root=gcc&view=rev Log: 2018-05-24 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 * resolve.c (resolve_fl_procedure): Avoid NULL dereference. 2018-05-24 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 * gfortran.dg/pr85780.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr85780.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Author: kargl Date: Fri May 25 18:28:51 2018 New Revision: 260768 URL: https://gcc.gnu.org/viewcvs?rev=260768&root=gcc&view=rev Log: 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * resolve.c (resolve_fl_procedure): Avoid NULL dereference. 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * gfortran.dg/pr85780.f90: New test. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr85780.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/resolve.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
Author: kargl Date: Fri May 25 19:05:52 2018 New Revision: 260771 URL: https://gcc.gnu.org/viewcvs?rev=260771&root=gcc&view=rev Log: 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * resolve.c (resolve_fl_procedure): Avoid NULL dereference. 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * gfortran.dg/pr85780.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr85780.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/resolve.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Author: kargl Date: Fri May 25 19:54:51 2018 New Revision: 260777 URL: https://gcc.gnu.org/viewcvs?rev=260777&root=gcc&view=rev Log: 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * resolve.c (resolve_fl_procedure): Avoid NULL dereference. 2018-05-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 Backport from trunk * gfortran.dg/pr85780.f90: New test. Added: branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr85780.f90 Modified: branches/gcc-6-branch/gcc/fortran/ChangeLog branches/gcc-6-branch/gcc/fortran/resolve.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed.
My original patch simply fixed the ICE, which then allowed the code to compile. In reality, an alternate return is not ISO C interoperable, so an error message is a more appropriate response. I have a patch. So, re-open.
Patch submitted. https://gcc.gnu.org/ml/fortran/2019-01/msg00236.html
Author: kargl Date: Fri Jan 25 17:55:25 2019 New Revision: 268277 URL: https://gcc.gnu.org/viewcvs?rev=268277&root=gcc&view=rev Log: 2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 * decl.c (gfc_match_subroutine): Check for conflict between BIND(C) and alternative return. 2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85780 * gfortran.dg/pr85780.f90: Update testcase for error message. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/pr85780.f90
Fixed on trunk. Closing.
*** Bug 88139 has been marked as a duplicate of this bug. ***