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

            Bug ID: 109861
           Summary: Optimization is marking  uninitialized  C_PTR being
                    passed to a C function, causes segfault.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brtnfld at hdfgroup dot org
  Target Milestone: ---

Created attachment 55085
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55085&action=edit
Fortran/C/Makfile. Changing the optimization level in the makefile reproduces
the behaviour.

For a TYPE(C_PTR), INTENT(OUT), buf, which is being passed through a Fortran
subroutine to get the value set in a C function, an optimization of >= -O1
gives the warning "used uninitialized [-Wuninitialized]" and then the program
Segmentation faults - invalid memory reference. It works for gfortran 12 but
fails for gfortran 13 and 14. It works if the INTENT is INOUT.

Reply via email to