https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103496

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to anlauf from comment #1)
> https://j3-fortran.org/doc/year/21/21-134r2.txt
> but it still requires using interoperable types etc.
> Just asking: did you simply forget to "decorate" your declarations?

If you talk about something like 'kind=c_int': On most systems, c_int ==
c_int32_t == 4 - and gfortran has (by default) a default integer == 4. But also
'kind=8' is very likely to be interoperable; whether it is with c_long or only
c_int64_t or ... does not really matter in case of c_sizeof – we just need to
know that some C type exists, which is interoperable.
[Likewise,  integer(kind=c_int128_t)  may or may not be interoperable,
depending whether that kind is available - and if not, c_int128_t should be a
negative number. (Ignoring for now that c_int128_t is a vendor extension.)]

But granted, usually you want to be sure that kind matches a specific C integer
type and then c_... becomes useful and more portable.

 * * *

'interoperable type': I have to admit that I tend to get confused whether
* "18.3.5 Interoperability of array variables"
applies or whether also
* "18.3.6 Interoperability of procedures and procedure interfaces"
applies. In the latter case, array descriptors are permitted - and that permits
allocatables, pointer, sub-sections etc. The former is more restrictive by only
permitting explicit shape or assumed size – while the latter permits more.

Given that the current wording for c_sizeof is about "that is not an
assumed-size array or an assumed-rank array that is associated with an
assumed-size array."
I think one reasonable reading is that 18.3.6 applies as 18.3.5 does not permit
assumed rank.

As 21-134r2 shows, the current wording is not ideal – but at the end, the
modification just implies that 18.3.5 applies (IMHO).

Reply via email to