https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124543

--- Comment #18 from Walter Spector <w6ws at earthlink dot net> ---
I guess it depends on ones definition of UNDEFINED vs UNKNOWN.  My opinion:

UNDEFINED - The file has been opened as unformatted, so could be bit streams,
bit groupings defined as integers, floats, control words surrounding records,
etc.

UNKNOWN - The file has been opened as formatted (and no encoding=) - so it does
have some form of character encoding.  We just don't know what it is.  So use a
default method of handling the characters.

Additionally, the way I read the 2nd half of the 2nd paragraph in the Standard
covers the case where some operating systems keep metadata about how the data
in a file is organized.  (Historically VAX/VMS and its follow-ons come to
mind.)  So an inquiry by file name could tap into this metadata and provide
useful info.

Interestingly, I just ran my test case with (a rather old version of) flang. 
It actually returns 'DEFAULT' for the formatted cases - which seems to be
allowed by the Standard:

$ flang inquire_encoding.f90
$ ./a.out
 No file, no preconnection (should be UNKNOWN):
 file= inquiry returned: UNKNOWN         : pass
 unit= inquiry returned: UNKNOWN         : pass

 formatted sequential (should be UNKNOWN):
 file= inquiry returned: DEFAULT         : FAIL
 unit= inquiry returned: DEFAULT         : FAIL

 formatted sequential UTF-8 (should be UTF-8):
 file= inquiry returned: UTF-8           : pass
 unit= inquiry returned: UTF-8           : pass

 unformatted sequential (should be UNDEFINED):
 file= inquiry returned: UNDEFINED       : pass
 unit= inquiry returned: UNDEFINED       : pass

 formatted stream (should be UNKNOWN):
 file= inquiry returned: DEFAULT         : FAIL
 unit= inquiry returned: DEFAULT         : FAIL

 unformatted stream (should be UNDEFINED):
 file= inquiry returned: UNDEFINED       : pass
 unit= inquiry returned: UNDEFINED       : pass

 formatted direct (should be UNKNOWN):
 file= inquiry returned: DEFAULT         : FAIL
 unit= inquiry returned: DEFAULT         : FAIL

 unformatted direct (should be UNDEFINED):
 file= inquiry returned: UNDEFINED       : pass
 unit= inquiry returned: UNDEFINED       : pass
$

Any idea what NAG or Intel/ifx return?  Since I retired, I no longer have
access to these compilers.

Reply via email to