https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
markeggleston at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |markeggleston at gcc dot gnu.org --- Comment #12 from markeggleston at gcc dot gnu.org --- (In reply to kargl from comment #6) > I do note there are other problems with get_environment_variable. It looks to me that this intrinsic supports the Fortran 2003 standard. Changes were introduced with the Fortran 2018 and support has not yet been implemented. > > 1) Neither length nor status can be integer(1). gfortran should issue > an error. Fortran 2003 has default kind for these arguments. > > 2) Fortran 2018 has added an optional errmsg argument. This is not > supported. > > 3) gfortran is issuing errors that don't make sence (to me). > > program foo > integer( 1) i01 > integer( 2) i02 > integer( 4) i04 > integer( 8) i08 > #ifdef __GFC_INT_16__ > integer(16) i16 > #endif > character(len=20) name > > print '(A,I0)', 'range(i01) = ', range(i01) > print '(A,I0)', 'range(i02) = ', range(i02) > print '(A,I0)', 'range(i04) = ', range(i04) > print '(A,I0)', 'range(i08) = ', range(i08) > #ifdef __GFC_INT_16__ > print '(A,I0)', 'range(i16) = ', range(i16) > #endif > > name = '' > ! Although valid Fortran, this should probably raise a warning. > call get_environment_variable(name); > > name = 'FOO' > call get_environment_variable(name,length=i01); ! Should be an error > call get_environment_variable(name,length=i02); ! Should be ok > call get_environment_variable(name,length=i04); ! Should be ok > call get_environment_variable(name,length=i08); ! Should be ok > #ifdef __GFC_INT_16__ > call get_environment_variable(name,length=i16); ! Should be ok > #endif > > end program foo > > mobile:kargl[256] gfcx -o z a.F90 && ./z > a.F90:29:45: > > 29 | call get_environment_variable(name,length=i01); ! Should be an > error > | 1 > Error: In call to 'get_environment_variable' at (1), type mismatch in > argument length'; pass 'INTEGER(1)' to 'INTEGER(4)' > a.F90:30:45: > > 30 | call get_environment_variable(name,length=i02); > | 1 > Error: In call to 'get_environment_variable' at (1), type mismatch in > argument length'; pass 'INTEGER(2)' to 'INTEGER(4)' > a.F90:32:45: > > 32 | call get_environment_variable(name,length=i08); > | 1 > Error: In call to 'get_environment_variable' at (1), type mismatch in > argument length'; pass 'INTEGER(8)' to 'INTEGER(4)' The mismatch errors are consistent with Fortran 2003 support. I think these issues should be in a separate PR for Fortran 2018 support.