From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6053C3858D39; Tue, 18 Oct 2022 23:18:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6053C3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666135113; bh=0Yjfj9e7gcv+zD199If3gE9fVYyYyJZR06evW0NDtVc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cGdOeVmus02V3nDofrGbcpI/7LOZ0y8xIqO0UTPDccIR50TgtopIRFVOvk35LlCMi BPnUPaNtlV6AcA+X8fr2AzGT2+vLSms63qBqfKtdmgJvhk++vvRAImqA+eIZap3My+ Lp5qtXeUO8hyVP2bmkEBehiUAyBjR8GoF2q2Er7o= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBmb3J0cmFuLzEwNzI2Nl0gUmVqZWN0IGtpbmQ9NCBjaGFy?= =?UTF-8?B?YWN0ZXJzIGZvciBCSU5EKEMpIOKAkyBpdCBpbnZhbGlkIGFuZCBnZW5lcmF0?= =?UTF-8?B?ZXMgd3JvbmcgY29kZQ==?= Date: Tue, 18 Oct 2022 23:18:33 +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: 13.0 X-Bugzilla-Keywords: accepts-invalid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107266 --- Comment #13 from Steve Kargl = --- On Tue, Oct 18, 2022 at 10:40:59AM +0000, burnus at gcc dot gnu.org wrote: >=20 > (In reply to kargl from comment #9) > > Please commit the patch in comment #7. character(kind=3D4) is not inte= roperable > > (unless C_CHAR is CHARACTER(KIND=3D4) which it isn't). This is an exte= nsion and > > gfortran should flag. >=20 > While I concur that the example in comment 1 is not interoperable accordi= ng to > the Fortran 2018 standard, I think the patch of comment 7 rejects too muc= h (cf. > '(b)' below.) >=20 > Still, I think something should/could be done =E2=80=93 hence, I did not = close this PR. > Namely: >=20 > * * * >=20 > For C interoperability, I think there are two parts to this: >=20 > (a.1) module m; character(kind=3D4) :: c; end module m > (a.2) subroutine foo(x) bind(C) > character(kind=3D4) :: x >=20 > To both the following applies (F2018, 18.3.1 Interoperability of intrinsic > types): >=20 > "A Fortran intrinsic type with particular type parameter values is > interoperable with a C type if the type and kind type parameter value are > listed in the table on the same row as that C type. If the type is charac= ter, > the length type parameter is interoperable=20 > if and only if its value is one." >=20 > Hence, neither 'foo' nor 'c' are interoperable. I'm confused by what you are trying to show with (a.1). The standard has "If the length is not specified in a char-selector or a * char-length, the length is 1.", so that last sentence is no relevant. Moreover, there is no C binding issue as you did not write module m character(kind=3D4), bind(c) :: c end module m gfortran accepts the above when it should be rejected because of C820 A variable with the BIND attribute shall be interoperable (18.3). For (a.2), this should also be rejected per C1556 A variable that is a dummy argument of a procedure that has ar proc-language-binding-spec shall be assumed-type or of interoperable type and kind type parameters. > (b) subroutine bar(x, y, z) bind(C) > character(kind=3D4,len=3D*) :: x > character(kind=3D4) :: y(:) > character(kind=3D4), allocatable :: z >=20 > This one is valid as F2018's "18.3.6 Interoperability of procedures and > procedure interfaces" states: >=20 It's not valid per C1556 above and=20 C1555 If proc-language-binding-spec is specified for a procedure, each dummy argument of type CHARACTER with the ALLOCATABLE or POINTER attribute shall have deferred character length.=