public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99922] Bind(C) with assumed length character should work Date: Tue, 06 Apr 2021 02:04:12 +0000 [thread overview] Message-ID: <bug-99922-4-GfnKskPtE1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99922-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99922 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-04-06 Status|UNCONFIRMED |NEW CC| |kargl at gcc dot gnu.org Priority|P3 |P4 Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to Brad Richardson from comment #0) > > So this is supposed to be allowed, and I can confirm that I can compile and > execute the above example and obtain the expected result with Intel (ifort > and icc). > What result did Intel produce? This patch suppresses the error message, which allows the code to compile. gfortran may produces wrong code. Someone else can investigate that issue diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 9039c9dca2a..b10a92ca234 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1549,19 +1549,21 @@ gfc_verify_c_interop_param (gfc_symbol *sym) sym->ns->proc_name->name); } - /* Character strings are only C interoperable if they have a - length of 1. */ - if (sym->ts.type == BT_CHARACTER && !sym->attr.dimension) + /* In F2008 (and earlier?) a character string is only C + interoperable if it has a length of 1. With F2018, if the + string is a dummy argument, it can have an assumed length if + the formal argument is CFI_cdesc_t. */ + if (sym->ts.type == BT_CHARACTER && !sym->attr.dimension + && !((gfc_option.allow_std & GFC_STD_F2018) && sym->attr.dummy)) { gfc_charlen *cl = sym->ts.u.cl; + if (!cl || !cl->length || cl->length->expr_type != EXPR_CONSTANT || mpz_cmp_si (cl->length->value.integer, 1) != 0) { - gfc_error ("Character argument %qs at %L " - "must be length 1 because " - "procedure %qs is BIND(C)", - sym->name, &sym->declared_at, - sym->ns->proc_name->name); + gfc_error ("Character argument %qs at %L must be length 1 " + "because procedure %qs is BIND(C)", sym->name, + &sym->declared_at, sym->ns->proc_name->name); retval = false; } }
next prev parent reply other threads:[~2021-04-06 2:04 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-05 23:18 [Bug fortran/99922] New: " everythingfunctional at protonmail dot com 2021-04-06 2:04 ` kargl at gcc dot gnu.org [this message] 2021-04-06 16:34 ` [Bug fortran/99922] " everythingfunctional at protonmail dot com 2021-10-22 20:42 ` sandra 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-99922-4-GfnKskPtE1@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).