https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117643
--- Comment #29 from anlauf at gcc dot gnu.org --- (In reply to Jerry DeLisle from comment #28) > --- snip --- > > > In iso-c-binding.def, one finds > > > > NAMED_CHARKNDCST (ISOCBINDING_CHAR, "c_char",gfc_default_character_kind) > > > > so kind('a') == kind(c_char_'a') on all targets. > > This implies that is_c_interop is a "don't care" if we check that type is > character and the kind is gfc_default_character_kind all should work > correctly. > > if (string->ts.type != BT_CHARACTER > || (string->ts.type == BT_CHARACTER > - && (string->ts.kind != 1 || string->ts.is_c_interop != 1))) > + && (string->ts.kind != gfc_default_character_kind))) > { > gfc_error ("%qs argument of %qs intrinsic at %L shall have " > "a type of CHARACTER(KIND=C_CHAR)", > > I have tested the above and all looks good to me. This is great. Go ahead. *** I frequently get confused by the details of interoperability. Reading the standard text again: F2023:18.3.1 Interoperability of intrinsic types "Table 18.2 shows the interoperability between Fortran intrinsic types and C types. A Fortran intrinsic type with particular type parameter values is interoperable with a C type if the type and kind type parameter value are listed in the table on the same row as that C type. ..." I now read this as being compatible with having kind('a') == kind(c_char_'a') on a particular processor (gfortran), and the above version of the check then looks entirely correct. (It is more complicated with interoperability of procedures (18.3.1), which fortunately is not relevant here.)