[J3] CFI_establish and elem_len for zero-length character strings and empty types/structs
Tobias Burnus
burnus at net-b.de
Thu Jul 22 07:40:32 UTC 2021
Hi all,
"" or ["", ""] has len(...) == 0. For the C array descriptor,
that matches elem_len = 0.
Likewise,
type, bind(C) :: t; end type
and
struct t {};
have c_sizeof()/sizeof() == 0, which implies elem_len = 0.
However, CFI_establish requires:
"elem_len – If type is equal to CFI_type_struct, CFI_type_other, or a Fortran
character type code, elem_len shall be greater than zero and equal to the
storage size in bytes of an element of the object."
The other CFI_... functions do not have the > 0 requirement (or != 0, as
size_t is unsigned and, hence, implies >= 0).
Tobias
More information about the J3
mailing list