[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 Martin Liška changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2019-02-25 Known to work||8.2.0 Blocks||63426 Target Milestone|--- |9.0 Ever confirmed|0 |1 Known to fail||9.0 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426 [Bug 63426] [meta-bug] Issues found with -fsanitize=undefined
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 Dominique d'Humieres changed: What|Removed |Added Keywords||ice-on-valid-code Priority|P3 |P4 CC||tkoenig at gcc dot gnu.org --- Comment #1 from Dominique d'Humieres --- Likely due to r268992 (the ICE occurs in the added block). The PR requires an instrumented compiler.
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 Thomas Koenig changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |tkoenig at gcc dot gnu.org
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 --- Comment #2 from Thomas Koenig --- This looks pretty obvious to me, at least looking at the -fdump-fortran-original dump. I will try to come up with a test case. Would it be possible to check that this also fixes the nullpointer offset access? Index: trans-types.c === --- trans-types.c (Revision 269161) +++ trans-types.c (Arbeitskopie) @@ -2988,9 +2988,9 @@ f = &sym->formal; for (a = actual_args; a != NULL; a = a->next) { + (*f) = gfc_get_formal_arglist (); if (a->expr) { - (*f) = gfc_get_formal_arglist (); snprintf (name, GFC_MAX_SYMBOL_LEN, "_formal_%d", var_num ++); gfc_get_symbol (name, NULL, &s); if (a->expr->ts.type == BT_PROCEDURE) @@ -3012,6 +3012,9 @@ s->attr.intent = INTENT_UNKNOWN; (*f)->sym = s; } + else + (*f)->sym = NULL; + f = &((*f)->next); } }
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 --- Comment #3 from Thomas Koenig --- This test case also segfaults with a non-instrumeted compiler: program main call sub(10, *10, 20) stop 1 10 continue end program main
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 --- Comment #4 from Martin Liška --- (In reply to Thomas Koenig from comment #2) > This looks pretty obvious to me, at least looking at the > -fdump-fortran-original dump. I will try to come up with > a test case. > > Would it be possible to check that this also fixes the > nullpointer offset access? > > Index: trans-types.c > === > --- trans-types.c (Revision 269161) > +++ trans-types.c (Arbeitskopie) > @@ -2988,9 +2988,9 @@ >f = &sym->formal; >for (a = actual_args; a != NULL; a = a->next) > { > + (*f) = gfc_get_formal_arglist (); >if (a->expr) > { > - (*f) = gfc_get_formal_arglist (); > snprintf (name, GFC_MAX_SYMBOL_LEN, "_formal_%d", var_num ++); > gfc_get_symbol (name, NULL, &s); > if (a->expr->ts.type == BT_PROCEDURE) > @@ -3012,6 +3012,9 @@ > s->attr.intent = INTENT_UNKNOWN; > (*f)->sym = s; > } > + else > + (*f)->sym = NULL; > + >f = &((*f)->next); > } > } I can confirm this works fine for the test-case as well as for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496#c3 Thanks for the fix.
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 Thomas Koenig changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #6 from Thomas Koenig --- Fixed, closing.
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 --- Comment #5 from Thomas Koenig --- Author: tkoenig Date: Tue Feb 26 19:10:00 2019 New Revision: 269226 URL: https://gcc.gnu.org/viewcvs?rev=269226&root=gcc&view=rev Log: 2019-02-26 Thomas Koenig PR fortran/89496 * trans-types.c (get_formal_from_actual_arglist): If the actual arglist has no expression, the corresponding formal arglist is an alternate return. 2019-02-26 Thomas Koenig PR fortran/89496 * gfortran.dg/altreturn_9_0.f90: New file. * gfortran.dg/altreturn_9_1.f90: New file. Added: trunk/gcc/testsuite/gfortran.dg/altreturn_9_0.f90 trunk/gcc/testsuite/gfortran.dg/altreturn_9_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-types.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/89496] [9 Regression] gcc/fortran/trans-types.c:3015:9: runtime error: member access within null pointer of type 'struct gfc_formal_arglist'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89496 Damian Rouson changed: What|Removed |Added CC||damian at sourceryinstitute dot or ||g --- Comment #7 from Damian Rouson --- Thanks for fixing this! It eliminates an ICE in a legacy code I'm currently modernizing.