https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66417
Bug ID: 66417 Summary: std::codecvt_utf16<char32_t, 0x10FFFF, std::codecvt_mode::generate_header> generates incorrect output Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: lcarreon at bigpond dot net.au Target Milestone: --- Created attachment 35696 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35696&action=edit Test program demonstrating the problem I am using Fedora 22 32-bit and 64-bit. I have discovered that the code conversion facet std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode::generate_header> has a problem. It generates the an incorrect big endian result. Please see the attached test program. I compiled the attached test program using the following command: g++ -std=c++14 -o test_utf16 test_utf16.cpp When I run the resulting executable, I get the following result: fe ff 41 0 42 0 43 0 ff fe 41 0 42 0 43 0 The first line above is the big endian result and the second line is the little endian result. Note that the BOM characters are in the right order but the succeeding characters in the big ending result are incorrect.