public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jeffrey.p.hill at nasa dot gov" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/108961] New: Segfault when associating to pointer from C_F_POINTER Date: Tue, 28 Feb 2023 00:22:25 +0000 [thread overview] Message-ID: <bug-108961-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108961 Bug ID: 108961 Summary: Segfault when associating to pointer from C_F_POINTER Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jeffrey.p.hill at nasa dot gov Target Milestone: --- Created attachment 54551 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54551&action=edit Full example of failing test In support of exposing a Fortran library via a C API, I am trying to implement C_F_STRPOINTER from the upcoming F202X standard in F2008: https://j3-fortran.org/doc/year/19/19-197r3.txt A sample implementation was provided in an earlier paper, as well as on the Intel forums: https://j3-fortran.org/doc/year/18/18-258r2.txt https://community.intel.com/t5/Intel-Fortran-Compiler/New-Interoperability-Fortran-to-C-String-case/m-p/1144681/highlight/true#M138173 Example usage is provided in this paper: https://j3-fortran.org/doc/year/21/21-107.txt Attachment #1 is a full example that implements and exercises c_f_strpointer per the above references. This works in ifort and nvfortran, but segfaults in all versions of gfortran I tested (4.8 => 11). Tests were done under Ubuntu and RH7. The problematic line is Line 37, when trying to associate the deferred-length output pointer with the defined-length pointer returned by c_f_pointer: call C_F_POINTER(CSTRPTR, p) FSTRPTR => p Attachment #2 in a minimal example that just focuses on the C_F_POINTER/pointer associate operations. I find the error only happens when the pointer to-be-associated is in a separate module with deferred length. Fall back is to simply copy the contents of the character array pointer into a character string, but I was hoping to get this approach working, which is zero-copy/zero-allocation. Thanks!
next reply other threads:[~2023-02-28 0:22 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-28 0:22 jeffrey.p.hill at nasa dot gov [this message] 2023-02-28 0:23 ` [Bug fortran/108961] " jeffrey.p.hill at nasa dot gov 2023-03-23 18:39 ` pault at gcc dot gnu.org 2023-04-18 9:17 ` pault at gcc dot gnu.org 2023-06-20 12:55 ` pault at gcc dot gnu.org 2023-06-21 16:02 ` cvs-commit at gcc dot gnu.org 2023-06-21 21:07 ` pault at gcc dot gnu.org 2023-07-29 20:18 ` anlauf at gcc dot gnu.org 2023-07-30 9:46 ` paul.richard.thomas at gmail dot com 2023-07-30 12:25 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108961-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).