public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Possible bug re: ISO_Fortran_binding.h
@ 2021-01-10 22:17 Harris Snyder
  2021-01-11 11:24 ` Tobias Burnus
  0 siblings, 1 reply; 10+ messages in thread
From: Harris Snyder @ 2021-01-10 22:17 UTC (permalink / raw)
  To: fortran

Hi everyone,

I've discovered a possible bug in libgfortran (regarding
ISO_Fortran_binding.h), but I'd like confirmation from the community
that this is indeed a bug before I work on a patch.

In the f2018 standard, the description of the argument `elem_len` to
`CFI_establish` reads:

`element_len` is ignored unless `type` is equal to `CFI_type_struct`,
`CFI_type_other`, or a Fortran character type code, in which case
`element_len` must be greater than zero and equal to the storage size
in bytes of an element of the object.

However in libgfortran, (as I discovered the hard way),
`CFI_type_signed_char`  and `CFI_type_int8_t` have the same numeric
representation. As a result, if you try to create an array of int8_t
without specifying the element_len as 1, you get seg faults or
floating point exceptions because it thinks the element size is zero.

The standard doesn't appear to say that these should be equivalent,
and it feels to me like a bug. Possible solutions:
- change the overall logic of how the numeric constants are mapped to types.
- treat int8_t as a special case and explicitly check for it when
converting from the standard specified array descriptor to the
gfortran array descriptor
- ..?

This is my first post to any GCC list, so I apologize if I've
miscategorized this message - feel free to correct me regarding
protocol.

Harris Snyder

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-14  3:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10 22:17 Possible bug re: ISO_Fortran_binding.h Harris Snyder
2021-01-11 11:24 ` Tobias Burnus
2021-01-11 15:42   ` Harris Snyder
2021-01-11 16:21     ` Tobias Burnus
2021-01-11 18:18       ` Harris Snyder
2021-01-12 14:30         ` Tobias Burnus
2021-01-12 19:20         ` [PATCH, Fortran] Bug fix in ISO_Fortran_binding - unsigned char arrays Harris Snyder
2021-01-13  6:34           ` Harris Snyder
2021-01-13 16:02             ` [PATCH, Fortran] PR fortran/93524 - ISO_Fortran_binding signed " Harris Snyder
2021-01-14  3:42               ` Jerry DeLisle

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).