public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
@ 2021-07-03 5:48 sandra at gcc dot gnu.org
2021-07-06 20:11 ` [Bug libfortran/101305] " sandra at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-03 5:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
Bug ID: 101305
Summary: Bind(C): Problems with incorrect kinds/sizes in
ISO_Fortran_binding.h and CFI_establish
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: sandra at gcc dot gnu.org
CC: burnus at gcc dot gnu.org, jrfsousa at gcc dot gnu.org
Target Milestone: ---
ISO_Fortran_binding.h incorrectly hard-codes literal data sizes into the
CFI_type_* macros that are only appropriate on a 64-bit target, such as
CFI_type_ptrdiff_t having the same kind (8) as CFI_type_int64_t. Even on
x86_64-linux-gnu, CFI_type_int_fast16_t and CFI_type_int_fast32_t have kinds
that are inconsistent with the sizes of the corresponding types as defined in
the system headers.
In addition, the standard says: "If a C type is not interoperable with a
Fortran type and kind supported by the Fortran processor, its macro shall
evaluate to a negative value." ISO_Fortran_binding.h doesn't handle that (I
think this mainly affects the 128-bit types GCC supports as an extension on
some targets).
There are related problems in CFI_establish in filling in the elem_len in the
descriptor from the kind. It incorrectly ends up giving zero elem_len to
CFI_type_cptr and CFI_type_cfunptr, and explicitly gives size 64(!) to long
double kind 10. It should probably reject unsupported types with
CFI_INVALID_TYPE.
There are test cases in the WIP TS 29113 testsuite:
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574115.html
interoperability/typecodes-array.f90
interoperability/typecodes-array-ext.f90
interoperability/typecodes-scalar.f90
interoperability/typecodes-scalar-ext.f90
library/establish.f90
This issue has some overlap with the set of bugs addressed by this patch from
José (PR fortran/100906/100907/100911/100914/100915/100916):
https://gcc.gnu.org/pipermail/fortran/2021-June/056154.html
but that patch is focused on the Fortran side of things rather than the C side.
Tobias and I both have WIP patches for this issue that need to be merged (his
is for handling detection of Fortran processor support, mine is to use sizeof
instead of hard-coding sizes). Probably all 3 pieces need to be in place for
this to work correctly.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
@ 2021-07-06 20:11 ` sandra at gcc dot gnu.org
2021-07-08 19:03 ` sandra at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-06 20:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #1 from sandra at gcc dot gnu.org ---
There's also some overlap with PR 100917, relating to long double. Getting rid
of the hard-coded kind/size assumptions will take care of at least the C side
of that issue.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
2021-07-06 20:11 ` [Bug libfortran/101305] " sandra at gcc dot gnu.org
@ 2021-07-08 19:03 ` sandra at gcc dot gnu.org
2021-07-14 0:08 ` sandra at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-08 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
sandra at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |sandra at gcc dot gnu.org
--- Comment #2 from sandra at gcc dot gnu.org ---
I'm working on patches for this.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
2021-07-06 20:11 ` [Bug libfortran/101305] " sandra at gcc dot gnu.org
2021-07-08 19:03 ` sandra at gcc dot gnu.org
@ 2021-07-14 0:08 ` sandra at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-14 0:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #3 from sandra at gcc dot gnu.org ---
Patches posted:
https://gcc.gnu.org/pipermail/fortran/2021-July/056236.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (2 preceding siblings ...)
2021-07-14 0:08 ` sandra at gcc dot gnu.org
@ 2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 4:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:
https://gcc.gnu.org/g:fef67987cf502fe322e92ddce22eea7ac46b4d75
commit r12-2551-gfef67987cf502fe322e92ddce22eea7ac46b4d75
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Thu Jul 8 08:21:20 2021 -0700
Bind(C): Fix type encodings in ISO_Fortran_binding.h
ISO_Fortran_binding.h had many incorrect hardwired kind encodings in
the definitions of the CFI_type_* macros. Additionally, not all
targets support all the defined type encodings, and the Fortran
standard requires those macros to have a negative value.
This patch changes ISO_Fortran_binding.h to use sizeof instead of
hard-coded sizes, and assembles it from fragments that reflect the
set of types supported by the target.
2021-07-22 Sandra Loosemore <sandra@codesourcery.com>
Tobias Burnus <tobias@codesourcery.com>
libgfortran/
PR libfortran/101305
* ISO_Fortran_binding.h: Fix hard-coded sizes and split into...
* ISO_Fortran_binding-1-tmpl.h: New file.
* ISO_Fortran_binding-2-tmpl.h: New file.
* ISO_Fortran_binding-3-tmpl.h: New file.
* Makefile.am: Add rule for generating ISO_Fortran_binding.h.
Adjust pathnames to that file.
* Makefile.in: Regenerated.
* mk-kinds-h.sh: New file.
* runtime/ISO_Fortran_binding.c: Fix include path.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (3 preceding siblings ...)
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 4:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:
https://gcc.gnu.org/g:c4dc9f590181321c36d3f3ef72c50b3c47bbfe7c
commit r12-2552-gc4dc9f590181321c36d3f3ef72c50b3c47bbfe7c
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Thu Jul 8 16:38:14 2021 -0700
Bind(C): Correct sizes of some types in CFI_establish
CFI_establish was failing to set the default elem_len correctly for
CFI_type_cptr, CFI_type_cfunptr, CFI_type_long_double, and
CFI_type_long_double_Complex.
2021-07-13 Sandra Loosemore <sandra@codesourcery.com>
libgfortran/
PR libfortran/101305
* runtime/ISO_Fortran_binding.c (CFI_establish): Special-case
CFI_type_cptr and CFI_type_cfunptr. Correct size of long double
on targets where it has kind 10.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (4 preceding siblings ...)
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 20:21 ` sandra at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 4:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:
https://gcc.gnu.org/g:a3b350f1799a1c0f9e2ece5b817a537fe42f0d2d
commit r12-2553-ga3b350f1799a1c0f9e2ece5b817a537fe42f0d2d
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Thu Jul 8 12:00:57 2021 -0700
Fix ISO_Fortran_binding.h paths in gfortran testsuite
ISO_Fortran_binding.h is now generated in the libgfortran build
directory where it is on the default include path. Adjust includes in
the gfortran testsuite not to include an explicit path pointing at the
source directory.
2021-07-27 Sandra Loosemore <sandra@codesourcery.com>
gcc/testsuite/
PR libfortran/101305
* gfortran.dg/ISO_Fortran_binding_1.c: Adjust include path.
* gfortran.dg/ISO_Fortran_binding_10.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_11.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_12.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_15.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_16.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_17.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_18.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_3.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_5.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_6.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_7.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_8.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_9.c: Likewise.
* gfortran.dg/PR94327.c: Likewise.
* gfortran.dg/PR94331.c: Likewise.
* gfortran.dg/bind_c_array_params_3_aux.c: Likewise.
* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Likewise.
* gfortran.dg/pr93524.c: Likewise.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (5 preceding siblings ...)
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 20:21 ` sandra at gcc dot gnu.org
2021-08-09 10:36 ` cvs-commit at gcc dot gnu.org
2021-08-10 15:27 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-28 20:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
sandra at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #7 from sandra at gcc dot gnu.org ---
Fixed on trunk.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (6 preceding siblings ...)
2021-07-28 20:21 ` sandra at gcc dot gnu.org
@ 2021-08-09 10:36 ` cvs-commit at gcc dot gnu.org
2021-08-10 15:27 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-09 10:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
https://gcc.gnu.org/g:527a1cf32c27a3fbeaf6be7596241570d864cc4c
commit r12-2808-g527a1cf32c27a3fbeaf6be7596241570d864cc4c
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Mon Aug 9 12:35:23 2021 +0200
testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660]
This patch adds -I$specdir/libgfortran to GFORTRAN_UNDER_TEST, when
set by proc gfortran_init. As the $specdir depends on the multilib
setting, it has to be re-set for a different multilib; hence, we track
whether a previous call to gfortran_init set that var or whether it
was set differently.
gcc/testsuite/
PR libfortran/101305
PR fortran/101660
* lib/gfortran.exp (gfortran_init): Add -I $specdir/libgfortran to
GFORTRAN_UNDER_TEST; update it when set by previous gfortran_init
call.
* gfortran.dg/ISO_Fortran_binding_1.c: Use <...> not "..." for
ISO_Fortran_binding.h's #include.
* gfortran.dg/ISO_Fortran_binding_10.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_11.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_12.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_15.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_16.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_17.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_18.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_3.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_5.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_6.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_7.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_8.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_9.c: Likewise.
* gfortran.dg/PR94327.c: Likewise.
* gfortran.dg/PR94331.c: Likewise.
* gfortran.dg/bind_c_array_params_3_aux.c: Likewise.
* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Likewise.
* gfortran.dg/pr93524.c: Likewise.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/101305] Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
` (7 preceding siblings ...)
2021-08-09 10:36 ` cvs-commit at gcc dot gnu.org
@ 2021-08-10 15:27 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-10 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101305
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
https://gcc.gnu.org/g:2ba0376ac40447ce7ee09fcef00511c18db25dfa
commit r12-2839-g2ba0376ac40447ce7ee09fcef00511c18db25dfa
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Tue Aug 10 17:26:32 2021 +0200
gfortran: Fix in-build-tree testing [PR101305, PR101660]
ISO_Fortran_binding.h is written in the build dir - hence, a previous
commit
added it as include directory for in-build-tree testing. However,
it turned out that -I$specdir/libgfortran interferes with reading .mod
files
as they are then no longer regareded as intrinsic modules. Solution:
Create
an extra include/ directory in the libgfortran build dir and copy
ISO_Fortran_binding.h to that directory. As -B$specdir/libgfortran already
causes gfortran to read that include subdirectory, the -I flag is no longer
needed.
PR libfortran/101305
PR fortran/101660
PR testsuite/101847
libgfortran/ChangeLog:
* Makefile.am (ISO_Fortran_binding.h): Create include/ in the build
dir
and copy the include file to it.
(clean-local): Add for removing the 'include' directory.
* Makefile.in: Regenerate.
gcc/testsuite/ChangeLog:
* lib/gfortran.exp (gfortran_init): Remove -I$specpath/libgfortran
from the string used to set GFORTRAN_UNDER_TEST.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-08-10 15:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-03 5:48 [Bug libfortran/101305] New: Bind(C): Problems with incorrect kinds/sizes in ISO_Fortran_binding.h and CFI_establish sandra at gcc dot gnu.org
2021-07-06 20:11 ` [Bug libfortran/101305] " sandra at gcc dot gnu.org
2021-07-08 19:03 ` sandra at gcc dot gnu.org
2021-07-14 0:08 ` sandra at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 4:24 ` cvs-commit at gcc dot gnu.org
2021-07-28 20:21 ` sandra at gcc dot gnu.org
2021-08-09 10:36 ` cvs-commit at gcc dot gnu.org
2021-08-10 15:27 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).