https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114355
Bug ID: 114355 Summary: Segfault passing missing optional dummy of bind(c) subroutine to optional assumed-rank dummy Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- Found while working out corner cases for pr101135: program main implicit none call test_c contains subroutine test_c (s) bind(c) real, dimension(:), optional :: s call test_ar (s) end subroutine test_ar (z) real, dimension(..), optional :: z end end This crashes at runtime when compiled with -O0 or -Og since gcc-9. The dump-tree has in test_c: { integer(kind=8) D.4362; struct array01_real(kind=4) parm.1; integer(kind=8) D.4369; struct array01_real(kind=4) * D.4370; D.4362 = s->dim[0].ubound; parm.1.span = s->span; parm.1.dtype = {.elem_len=4, .version=0, .rank=1, .type=3}; D.4369 = s->dim[0].stride; parm.1.dim[0].lbound = 1; parm.1.dim[0].ubound = D.4362; parm.1.dim[0].stride = NON_LVALUE_EXPR <D.4369>; parm.1.data = (void *) s->data; parm.1.offset = -NON_LVALUE_EXPR <D.4369>; D.4370 = s != 0B ? &parm.1 : 0B; test_ar (D.4370); } Looks like there are several potential NULL pointer dereferences.