What happens. A character declaration whose length is an expression containing a comma fails to parse when the kind is given before the length, or positionally:
character(kind=ck, len=max(n, 0)), pointer :: tmp ! FortranSyntaxError
character(max(n, 0), ck) :: s ! FortranSyntaxError
Error: Intrinsic 'MAX' expects at least 2 args but found 1.
The length-first form parses correctly:
character(len=max(n, 0), kind=ck), pointer :: tmp ! OK
Cause. In Char_Selector.match, the kind-first and positional branches omit the repmap() call that restores comma-hidden sub-expressions (present in the length-first branch), so the inner comma of the length expression stays hidden and the intrinsic argument-count check sees one argument.
Minimal module reproducer:
module m
implicit none
integer, parameter :: ck = 1
contains
subroutine s(n)
integer, intent(in) :: n
character(kind=ck, len=max(n, 0)), pointer :: tmp
end subroutine s
end module m
I am attaching PR #520 that should solve this. Thank you, Federico
What happens. A
characterdeclaration whose length is an expression containing a comma fails to parse when the kind is given before the length, or positionally:Error:
Intrinsic 'MAX' expects at least 2 args but found 1.The length-first form parses correctly:
Cause. In
Char_Selector.match, the kind-first and positional branches omit therepmap()call that restores comma-hidden sub-expressions (present in the length-first branch), so the inner comma of the length expression stays hidden and the intrinsic argument-count check sees one argument.Minimal module reproducer:
I am attaching PR #520 that should solve this. Thank you, Federico