https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102368
kargls at comcast dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargls at comcast dot net
--- Comment #11 from kargls at comcast dot net ---
(In reply to Thomas Koenig from comment #6)
> I think the code is valid.
>
> A named scalar Fortran variable is interoperable if and only if its type and
> type parameters are interoperable,
>
> check
>
> it is not a coarray,
>
> check
>
> it has neither the ALLOCATABLE nor the POINTER attribute
>
> check
>
> and if it is of type character
>
> its length is not assumed or declared by an expression that is not a constant
> expression
>
> The length of
>
> character(kind=c_char, len=*), parameter :: blergh = 'abc'
>
> is three, the * in "len=*" is a type paremater.
It seems to me that J3 was trying to carve out an exception for
a named constant.
18.3.5 Interoperability of scalar variables
A named scalar Fortran variable is interoperable if and only if
its type and type parameters are interoperable, ... and if it is
of type character its length is not assumed or declared by an
expression that is not a constant expression.
As an (american) English speaker, I must admit that I find parsing
the last part of the above rather challenging. It would seem to me
that the "its length is not assumed" applies to a dummy argument.
So we have the following
its length is not declared by an expression that is not a
constant expression.
or
its length is declared by an expression that is not a constant
expression.
The former has a double negative, which is an odd construct; so,
let's start with the latter. Well, 'abc' is a constant expression,
and the latter does not make sense. If we eliminate the double
negative, we have
its length is declared by an expression that is a constant
expression.
I suppose the confusion comes from
F2023, p. 71:
...
A char-length type parameter value of * has the following meanings.
...
ยท If used to declare a named constant, the length is that of the
constant value.
character(kind=c_char, len=*), parameter :: blergh = 'abc'
The length is 3 for the named constant 'blergh'.
F2023, 18.3.1 Interoperability of intrinsic types
...
If the type is character, the length type parameter is interoperable
if and only if its value is one.
This certainly appears to contradict 18.3.5.