[Bug fortran/109861] Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109861 Scot Breitenfeld changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|--- |INVALID
[Bug fortran/109861] Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109861 --- Comment #6 from Scot Breitenfeld --- Thanks for the standard reference. That is indeed what I was looking for. I understand now that, in this case, the INTENT refers to whether C_PTR can be changed and does not relate to the INTENT state of the target. I should change all my usage cases to INTENT(IN) since none of the Fortran wrappers allow changes to the pointer itself.
[Bug fortran/99982] INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 --- Comment #11 from Scot Breitenfeld --- Thanks for the standard reference. That is indeed what I was looking for. I understand now that, in this case, the INTENT refers to whether C_PTR can be changed and does not relate to the INTENT state of the target. I should change all my usage cases to INTENT(IN) since none of the Fortran wrappers allow changes to the pointer itself.
[Bug fortran/109861] Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109861 --- Comment #3 from Scot Breitenfeld --- I see the same issue with NAG, regardless of the optimization level. Our CI testing had missed it because this was a parallel test, and we don't test parallel with NAG. I guess the issue is whether marking TYPE(C_PTR) as CLOBBER is correct. I looked through the 2018 standard and could not locate anything that addresses this use case. Are you interpreting the possibility that a TYPE(C_PTR) should not be declared INTENT(OUT)? I can instead change the subroutine to declare buf as INTEGER(C_INT), INTENT(OUT), TARGET :: buf and f_ptr = C_LOC(buf) and there is no issue. So it seems to depend on the TYPE of the argument being passed.
[Bug fortran/109861] New: Optimization is marking uninitialized C_PTR being passed to a C function, causes segfault.
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=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.
[Bug fortran/99982] INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 --- Comment #9 from Scot Breitenfeld --- This is Great! Thank-you.
[Bug fortran/99982] INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 --- Comment #5 from Scot Breitenfeld --- I removed the c_funptr interface in CGNS since it was not being used.
[Bug fortran/99982] INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 --- Comment #4 from Scot Breitenfeld --- Is there an update on this issue, the CGNS fortran wrappers will not work with gfortran as there are no work arounds for this issue. Thanks.
[Bug fortran/100149] Seg fault passing to CHARACTER(*), DIMENSION(*), INTENT(IN), OPTIONAL
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100149 Scot Breitenfeld changed: What|Removed |Added Known to work||10.3.0 Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #3 from Scot Breitenfeld --- For future reference, gfortran 10.3.0 does not have this issue. I've updated the Known to work. The bug report can be closed.
[Bug fortran/100149] Seg fault passing to CHARACTER(*), DIMENSION(*), INTENT(IN), OPTIONAL
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100149 --- Comment #2 from Scot Breitenfeld --- Thanks for the update; it is good to know that it was fixed in 11.0. I also tried it with GCC master (4.20.2021), and it worked. This is for an open-source library (CGNS), and it is a commonly used API; it is a show-stopper bug. Thanks again.
[Bug fortran/99982] INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 --- Comment #1 from Scot Breitenfeld --- I checked with gcc master (4/20/2021), and it still has the same issue.
[Bug fortran/100149] New: Seg fault passing to CHARACTER(*), DIMENSION(*), INTENT(IN), OPTIONAL
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100149 Bug ID: 100149 Summary: Seg fault passing to CHARACTER(*), DIMENSION(*), INTENT(IN), OPTIONAL Product: gcc Version: 10.2.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 50631 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50631=edit The program has two lines of doing that same thing, the lines are marked which fail. The attached program fails with: Program received signal SIGSEGV, Segmentation fault. 0x143c783f in __memmove_sse2_unaligned_erms () from /lib64/libc.so.6 The program worked with 10.1.0 (and 9.3.1, 7.5.0) and fails with 10.2.0
[Bug fortran/99982] New: INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99982 Bug ID: 99982 Summary: INTERFACE selects wrong module procedure involving C_PTR and C_FUNPTR Product: gcc Version: 10.2.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 50532 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50532=edit program uses interface and module procedure to select between subroutines with type C_PTR and C_FUNPTR The attached program always selects the TYPE(C_FUNPTR) when selecting between a (overloaded) subroutine with TYPE(C_PTR) and TYPE(C_FUNPTR), even when the variable type is TYPE(C_PTR). It does this for both passing a variable as the argument or using the C_LOC or c_funloc directly in the call. I tried it with 7.5.0, 10.2.0, same behavior. Intel and NAG both select the correct subroutine.