https://gcc.gnu.org/g:3e2c1324fadb1a9e422e83187083d231bbe8dec2
commit r16-8514-g3e2c1324fadb1a9e422e83187083d231bbe8dec2 Author: Jerry DeLisle <[email protected]> Date: Mon Apr 6 17:55:21 2026 -0700 fortran: Fix encoding value when file/unit opened without specifying. When a file or unit is connected as a formatted I/O and the OPEN statement does not set the ENCODING it is set to DEFAULT. PR libfortran/124543 libgfortran/ChangeLog: * io/inquire.c (inquire_via_unit): Change the returned encoding value to 'DEFAULT' when not specified in the OPEN statement. gcc/testsuite/ChangeLog: * gfortran.dg/pr124543.f90: Add the dg-options "-O0" to reduce testing time. Adjust test for the change above. Diff: --- gcc/testsuite/gfortran.dg/pr124543.f90 | 10 +++++----- libgfortran/io/inquire.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/pr124543.f90 b/gcc/testsuite/gfortran.dg/pr124543.f90 index 2ab5b5a023b4..e434599d6c7f 100644 --- a/gcc/testsuite/gfortran.dg/pr124543.f90 +++ b/gcc/testsuite/gfortran.dg/pr124543.f90 @@ -1,5 +1,5 @@ -! { dg-do run ) - +! { dg-do run } +! { dg-options "-O0" } ! PR124543, test case derived from that in the PR with several ! corrections. Some of the logic which was inverted. Some INQUIRE ! statements were missing the EXISTS. Segfaults now fixed. @@ -164,7 +164,7 @@ program inq_tests inquire (file=lfn, decimal=decimal, encoding=encoding, pos=pos, & round=round, sign=signc, stream=stream, iostat=iostat) if (decimal /= 'POINT' .or. (iostat /= 0)) stop 166 - if (encoding /= 'UNKNOWN') stop 167 + if (encoding /= 'DEFAULT') stop 167 if (round /= 'PROCESSOR_DEFINED') stop 168 if (signc /= 'PROCESSOR_DEFINED') stop 169 if (stream /= 'NO') stop 170 @@ -202,7 +202,7 @@ program inq_tests inquire (unit=lun, decimal=decimal, encoding=encoding, pos=pos, & round=round, sign=signc, stream=stream, iostat=iostat) if (decimal /= 'POINT' .or. (iostat /= 0)) stop 204 - if (encoding /= 'UNDEFINED') stop 205 + if (encoding /= 'DEFAULT') stop 205 if (round /= 'PROCESSOR_DEFINED') stop 206 if (signc /= 'PROCESSOR_DEFINED') stop 207 if (stream /= 'NO') stop 208 @@ -246,7 +246,7 @@ program inq_tests inquire (file=lfn, decimal=decimal, encoding=encoding, pos=pos, & round=round, sign=signc, stream=stream, recl=recl, iostat=iostat) if (decimal /= 'UNDEFINED' .or. (iostat /= 0)) stop 248 - if (encoding /= 'UNKNOWN') stop 249 + if (encoding /= 'UNDEFINED') stop 249 if (round /= 'PROCESSOR_DEFINED') stop 250 if (signc /= 'PROCESSOR_DEFINED') stop 251 if (stream /= 'YES') stop 252 diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c index 4d773349fa37..007fd6a312ac 100644 --- a/libgfortran/io/inquire.c +++ b/libgfortran/io/inquire.c @@ -317,7 +317,7 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u) switch (u->flags.encoding) { case ENCODING_DEFAULT: - p = "UNDEFINED"; + p = "DEFAULT"; break; case ENCODING_UTF8: p = "UTF-8"; @@ -325,8 +325,8 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u) default: internal_error (&iqp->common, "inquire_via_unit(): Bad encoding"); } - else - p = "UNKNOWN"; + else + p = "UNDEFINED"; cf_strcpy (iqp->encoding, iqp->encoding_len, p); }
