From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5EC0C3858D20; Mon, 19 Feb 2024 18:13:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC0C3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708366427; bh=IHeq7H2oC4NQseElnmJ8P22Et1K1Dr5XenKoqr/AYOI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YOwoVflrDFZ96WFCrexQDhUI5MfPT1WhjoGV89ijxAJOczg3OH1Fw/MVZLzwtH7FU ZucOeJ0G5i682CeT7I+pcOI3WK4gM/9Z+L03zMQhT8+K5UE+J6YrYFazyj5uxQFc+7 BUO04oN3P+vEqRUPdl98+UBEyt/jSxUsILWuVNlI= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113997] Bogus 'Warning: Interface mismatch in global procedure' with C binding Date: Mon, 19 Feb 2024 18:13:47 +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: 14.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org 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: 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=3D113997 --- Comment #3 from Tobias Burnus --- > Anyway, renaming the binding label, like > subroutine acc_attach_c(x) bind(C, name=3D"acc_attach_renamed") > makes the code compile. Well, the code *does* compile as it is only a warning. * * * I think the problem here is a bit that on the Fortran-user side ('acc_attac= h' vs. 'acc_attach_c') and on the assembler-level side ('acc_attach_' vs. 'acc_attach') everything is fine (except with -fno-underscore) but, admitte= dly, not from the Fortran lanaguage side. (On the other hand, Fortran itself is perfectly happy with: 'subroutine foo' and 'subroutine bar() Bind(C, name=3D'foo_')' but that will break with most Fortran compilers.) Thus, the question is whether we (gfortran) want to do something here - or = are happy with issuing the semi-correct/semi-bogus warning here. * * * And renaming "acc_attach_c" does not really help as 'acc_attach' with C bin= ding does exist. In this case it exists as: =20 https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dlibgomp/oacc-mem.c;hb=3Dr= efs/heads/master#l944 and renaming would just add another wrapper around it. However, an alternative is the following - which is (nearly) identical, exc= ept that GCC does some GFC-CFC and back conversations =E2=80=93 independent whe= ther implemented in C or in Fortran: subroutine acc_attach(x) bind(C, name=3D"acc_attach_") use iso_c_binding, only : c_loc implicit none (external, type) type(*), dimension(..), target :: x interface subroutine acc_attach_c(x) bind(C, name=3D"acc_attach") use iso_c_binding type(c_ptr) :: x end subroutine end interface call acc_attach_c(c_loc(x)) end=