From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4CAE7386F44E; Thu, 11 Jan 2024 18:48:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CAE7386F44E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704998884; bh=iDG8s/JKU8zdlvM5BiVRmgiOn5FH82MHj16IPcvmXbc=; h=From:To:Subject:Date:From; b=Vtg9GNGAGJywkTcrdnJUnb0sxVn6ZOYHOXB6QKATj8zElJtwGLFOa+P7/+hacOzEM UNWI9tugmfJKrogYKbp4ailrJS4lKYqj8m+1I3zbsMb467AIeg4gidPBnYDpzxw1LJ ZxyhEUCFnszyTetCq1ExXeMteCwM9oqIw6W1xeqs= From: "everythingfunctional at protonmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113338] New: Valid Code Rejected, bind(C) procedure with pointer argument Date: Thu, 11 Jan 2024 18:48:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: everythingfunctional at protonmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D113338 Bug ID: 113338 Summary: Valid Code Rejected, bind(C) procedure with pointer argument Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: everythingfunctional at protonmail dot com Target Milestone: --- The following example is rejected by gfortran, but should be valid. Fortran Program: program example use iso_c_binding implicit none type :: t integer :: i end type interface subroutine c_proc(x) bind(c) import t implicit none type(t), pointer, intent(in) :: x end subroutine end interface type(t), target :: x x%i =3D 42 call c_proc(x) contains subroutine f_proc(x) bind(c) type(t), pointer, intent(in) :: x print *, x%i end subroutine end program C code: #include extern void f_proc(CFI_cdesc_t* x); extern void c_proc(CFI_cdesc_t* x) { f_proc(x); } Is rejected with the following messages: main.f90:11:27: 11 | subroutine c_proc(x) bind(c) | 1 Error: Variable =E2=80=98x=E2=80=99 at (1) is a dummy argument to the BIND(= C) procedure =E2=80=98c_proc=E2=80=99 but is not C interoperable because derived type = =E2=80=98t=E2=80=99 is not C interoperable main.f90:23:23: 23 | subroutine f_proc(x) bind(c) | 1 Error: Variable =E2=80=98x=E2=80=99 at (1) is a dummy argument to the BIND(= C) procedure =E2=80=98f_proc=E2=80=99 but is not C interoperable because derived type = =E2=80=98t=E2=80=99 is not C interoperable But the standard says: > A Fortran procedure interface is interoperable with a C function prototyp= e if > ... > (5) any dummy argument without the VALUE attribute corresponds to a forma= l parameter of the prototype that is of a pointer type, and either > ... > * the dummy argument is allocatable, assumed-shape, assumed-rank, or a po= inter without the CONTIGUOUS attribute, and the formal parameter is a point= er to CFI_cdesc_t I.e., that argument need not be interoperable, because it has the pointer attribute.=