Hi Harald,
On 10/14/20 8:25 PM, Harald Anlauf wrote:
Or worded differently: If
integer, parameter :: A(*) = [(i, i=1,5)]
is valid, which should
integer, parameter :: B(*) = [integer :: (int(i, kind=i), i=1,2)]
be invalid?
Well, my copy of the F2018-FDIS says about the KIND argument to INT:
"KIND (optional) shall be a scalar integer constant expression."
Which applies to "B". For "A" (PARAMETER) it states: "entity has the
value specified byits constant-expr,"
Are you saying that (int(i, kind=i), i=1,2) is legal?
It would be helpful if you explained why "i" in kind=i is a constant expression.
I only say that it might be valid. – It would be likewise helpful if you
could explain why "i" is a const-expr in "[(i, i=1,5)]" – which we agree
is valid, don't we?. And what about "i" in "int(i)" for "[(kind(i),
i=1,5)]"?
I don't know whether it is valid – I just find it not obvious that [(i,
i=1,5)] is valid and [(int(1, kind=i), i=1,1)] is not.
Surely, if one first expands the array, it is valid: "[integer ::
(int(i, kind=i), i=1,2)]" → "[integer :: int(1, kind=1), int(2,kind=2)]"
→ "[integer :: 1_1, 2_2]" → "[1,2]".
In any case, gfc_check_init_expr is supposed to check for const-expr –
and if that does not work, gfc_check_init_expr should be fixed or at
least clearly understood when it can be used and when it cannot be used.
Tobias
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter