https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79511
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think this is the fix for comment 9:
--- a/libstdc++-v3/src/c++11/codecvt.cc
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -1483,7 +1483,11 @@ do_in(state_type&, const extern_type* __from, const
extern_type* __from_end,
{
range<const char> from{ __from, __from_end };
range<wchar_t> to{ __to, __to_end };
- auto res = utf16_in(from, to, _M_maxcode, _M_mode);
+ codecvt_mode mode = codecvt_mode(_M_mode &
(consume_header|generate_header));
+#if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
+ mode = codecvt_mode(mode | little_endian);
+#endif
+ auto res = utf16_in(from, to, _M_maxcode, mode);
__from_next = from.next;
__to_next = to.next;
return res;