From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86B91388CC19; Tue, 6 Apr 2021 02:04:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86B91388CC19 From: "kargl at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on bug_status cc priority everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 02:04:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99922 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) >=20 > So this is supposed to be allowed, and I can confirm that I can compile a= nd > execute the above example and obtain the expected result with Intel (ifort > and icc). >=20 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 =3D=3D 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 =3D=3D BT_CHARACTER && !sym->attr.dimension + && !((gfc_option.allow_std & GFC_STD_F2018) && sym->attr.dumm= y)) { gfc_charlen *cl =3D sym->ts.u.cl; + if (!cl || !cl->length || cl->length->expr_type !=3D EXPR_CON= STANT || mpz_cmp_si (cl->length->value.integer, 1) !=3D 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,= =20 + &sym->declared_at, sym->ns->proc_name->name); retval =3D false; } }=