From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 141D53864858; Sun, 11 Jul 2021 20:55:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 141D53864858 From: "sandra at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100917] Bind(c): errors handling long double real Date: Sun, 11 Jul 2021 20:55:17 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sandra 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 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: Sun, 11 Jul 2021 20:55:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100917 --- Comment #6 from sandra at gcc dot gnu.org --- I've been thinking some more about this issue. It seems to me that a "prop= er" solution is either (1) Add a kind field to the GFC descriptor or (2) Do away with GFC descriptors and use the C descriptor layout and encodings everywhe= re.=20 Both of these break ABI. (2) is more work to implement but more maintainab= le long term, also more efficient at runtime. To be more specific about the problem here.... on x86 targets, real(kind= =3D10) in Fortran or long double in C is an 80-bit representation. On 32-bit processors it has size 12 but on 64-bit processors it needs to be padded to= 16 bytes. Thus, if we only have elem_len=3D16 in the descriptor, we can't tel= l if it is the 80-bit representation or the true 128-bit _float128 representation when that is also available. For a workaround that does not change the ABI, the best ideas I've had are either mapping CFI_type_long_double and CFI_type_float128 to the same value= on targets where the two types both have size 16, or one of them to a negative value to indicate it's not interoperable on that target. In practice it's probably rare for user code to have to use the typecode to distinguish betw= een floating-point formats -- you define your C function to accept the type of arguments you intend to pass into it. Anyway, a workaround for the floating-point stuff still leaves the character size vs character length problem unaccounted for.=