public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114355] New: Segfault passing missing optional dummy of bind(c) subroutine to optional assumed-rank dummy
@ 2024-03-15 17:02 anlauf at gcc dot gnu.org
  2024-03-15 17:12 ` [Bug fortran/114355] " anlauf at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-03-15 17:02 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug fortran/114355] Segfault passing missing optional dummy of bind(c) subroutine to optional assumed-rank dummy
  2024-03-15 17:02 [Bug fortran/114355] New: Segfault passing missing optional dummy of bind(c) subroutine to optional assumed-rank dummy anlauf at gcc dot gnu.org
@ 2024-03-15 17:12 ` anlauf at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-03-15 17:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114355

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #1 from anlauf at gcc dot gnu.org ---
Works fine with Intel, NAG, NVidia, flang.

Apparently no crash with gcc-7, gcc-8, but not further tested whether the
generated code is fine.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-15 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-15 17:02 [Bug fortran/114355] New: Segfault passing missing optional dummy of bind(c) subroutine to optional assumed-rank dummy anlauf at gcc dot gnu.org
2024-03-15 17:12 ` [Bug fortran/114355] " anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).