J3/01-234r1 Date: 2001/06/04 To: J3 From: /Interop Subject: Unresolved issue 246 Ref: C99 standard Edits and references are to J3/01-007r1. Issue 246: [388: 30-40] 1. Summary There is a hole in the interoperability of Fortran scalar intrinsic entities and C entities: Only unqualified C entities interoperate with Fortran scalar intrinsic entities. Qualified C entities currently cannot interoperate with Fortran scalar intrinsic entities. This paper gives more detail on the hole, and gives a solution. 2. Description 01-007r1 specifies in section 16.2.1 for the interoperability of Fortran scalar intrinsic entities and C entities that a "scalar Fortran entity ... is interoperable with a scalar C entity of any type compatible with the indicated C type in the same row of the table." Compatibility is defined in section 6.2.7 of the C standard: "Two types have compatible type if their types are the same." However, quoting from section 6.7.3 of the C standard: "For two qualified types to be compatible, both shall have the identically qualified version of a compatible type; the order of type qualifiers within a list of specifiers or qualifiers does not affect the specified type." The type qualifiers are defined in section 6.7.3 of the C standard to be "const", "restrict" and "volatile". The result is that draft Fortran 2000 does not allow Fortran scalar entities to interoperate with qualified C types, because these are not compatible with the unqualified C types. For example, an entity of type integer with kind C_INT interoperates with a C entity of type "int", but cannot interoperate with a C entity of type "const int", because these two C entities are not compatible. In order to allow an entity of type integer with kind C_INT to interoperate with qualified versions of compatible C types, we propose to extend the specification of interoperability to also include these qualified versions. Note that two C types are compatible, even though their storage-class specifiers might differ. For instance "register int" is compatible with "int". Thus interoperability already covers C entities with storage-class specifiers. 3. Edits [388:22-25] Change the following sentence "A scalar Fortran entity that has neither the POINTER nor the ALLOCATABLE attribute, and is of the indicated type and kind type parameter, is interoperable with a scalar C entity of any type compatible with the indicated C type in the same row of the table." to "A scalar Fortran entity that has neither the POINTER nor the ALLOCATABLE attribute, and is of the indicated type and kind type parameter, is interoperable with a scalar C entity whose unqualified type is compatible with the indicated C type in the same row of the table. See 6.2.5 and 6.2.7 of the C standard for definitions of unqualified types and compatible types." [388:30-40] Delete J3 note [390:11] Change the following sentence "Instead a user can use the signed kinds of integers to interoperate with the unsigned types as well." to "Instead a user can use the signed kinds of integers to interoperate with the unsigned types and all their qualified versions as well."