https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80888
Bug ID: 80888 Summary: Wide_Text_IO defaults to bracket encoding even if -gnatW8 specified Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: simon at pushface dot org Target Milestone: --- Host: x86_64-apple-darwin15 The GNAT reference manual says in 11.6 Wide_Text_IO <https://gcc.gnu.org/onlinedocs/gnat_rm/Wide_005fText_005fIO.html>, "The default encoding method for the standard files, and for opened files for which no WCEM parameter is given in the FORM string matches the wide character encoding specified for the main program (the default being brackets encoding if no coding method was specified with -gnatW)." This is slightly wrong, in that the UTF-8 coding method is selected even in the absence of -gnatW8 if the main program's source file has the appropriate BOM; but the point of this PR is that it is not in fact true, and even if -gnatW8 is given files are created/opened with bracket encoding unless the Form parameter is given (Form => "wcem=8"). The attached demonstrator shows this. The file as uploaded begins with EF BB BF, but compile with -gnatW8 to be sure: $ gnatmake utf8_encoding -gnatW8 gcc -c -gnatW8 utf8_encoding.adb gnatbind -x utf8_encoding.ali gnatlink utf8_encoding.ali $ ./utf8_encoding Two files are created, one without the Form parameter: $ od -tx1 -c -N32 file_without_form 0000000 5b 22 30 33 43 30 22 5d 72 b2 68 0a [ " 0 3 C 0 " ] r 262 h \n 0000014 and one with: $ od -tx1 -c -N32 file_with_form 0000000 cf 80 72 c2 b2 68 0a π ** r ² ** h \n 0000007