> Hi,
> this patchs makes fortran's C_SIGNED_CHAR and C_SIZE_T interoperable with 
> signed char and size_t as standard require.  There are two issues here.
> 
> First Fortran integers are always signed, but the standard insist on the
> signed integer to match C size_t that is unsigned (if it was ptrdiff_t, we 
> would
> be better of) and similarly the standard seems to explicitly state that
> C_SIGNED_CHAR is interoperable with both signed char and unsigned char.
> I thus globbed all integer types of precision compatible either with char
> or size_t to be the same regardless the signedness.
Hmm, actually there is a note:
  NOTE 15.8
  ISO/IEC 9899:1999 specifies that the representations for nonnegative signed
  integers are the same as the corresponding values of unsigned integers.
  Because Fortran does not provide direct support for unsigned kinds of 
integers,
  the ISO C BINDING module does not make accessible named constant s for their
  kind type parameter values.  A user can use the signed kinds of integers to
  interoperate with the unsigned types and  all  their  qualified  versions  as
  well.   This  has  the  potentially  surprising  side  ect  that  the  C  type
  unsigned char is interoperable with the type integer with a kind type 
parameter
  of C SIGNED CHAR

This seems to imply that other integer types also should be interoperable 
regardless
of the signedness.  It is true that representation is same for C, but alias 
sets are
not.  Perhaps all of the C BINDING types shall just be dropped to alias set 0? 
That
would also solve the inter-operability of char versus char[1].

I would say that the note is non-normative, so perhaps it can just be ignored, 
too :)

Honza

Reply via email to