[flang] All STAT= specifier should be an integer that's at least 16-bit.
In the PR#230031, @bonachea mentionned this behavior that flang doesn't follow:
F2023 9.7.4 also says (same in F2018):
R946 stat-variable is scalar-int-variable
A stat-variable should have a decimal exponent range of at least four; otherwise the processor-dependent error code might not be representable in the variable.
In plain English, the implication is the standard requires the argument to STAT to be an integer that's at least 16-bit.
But flang currently silently accepts 8-bit integers to STAT=:
cgpu$ cat stat2.F90
program stat_test
use iso_c_binding
integer :: coarray[*]
integer(C_INT8_T) :: myint8
integer(C_INT16_T) :: myint16
coarray[1, stat=myint8] = 0 ! violates F2023 9.7.4
coarray[1, stat=myint16] = 0 ! ok
end program
cgpu$ flang -fsyntax-only stat2.F90
I'm on it
What do the other compilers do? Maybe it should be '-pedantic' warning?
@eugeneepshteyn gfortran doesn't throw an error and accepts this. So I suppose adding an error might break a lot of existing code. I think it's actually best to treat this as a '-pedantic' warning
Yeah, I was thinking that the user may know something about the runtime codes and may have a good reason to use 8 bit variable. Having -pedantic warning would be valuable to catch mistakes.
Oh, since flang will only warn at -pedantic, it probably needs a sentence description in Extensions.md.