On 19/04/16 19:07 +0100, Jonathan Wakely wrote:
This was reported as a bug in the Filesystem library, but it's
actually a problem in the codecvt_utf8 facet that it uses.

The fix had a silly typo meaning it didn't work for big endian
targets, which was revealed by the improved tests I added.

Tested x86_64-linux and powerpc64-linux, committed to trunk.


commit 3a57afb171190fc8554d68094f9d4e3d2d0b2576
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Wed Apr 20 17:44:50 2016 +0100

    Fix std::codecvt_utf8* for big-endian targets
    
    	PR libstdc++/69703
    	* src/c++11/codecvt.cc (__codecvt_utf8_base<char16_t>::do_in,
    	__codecvt_utf8_utf16_base<char16_t>::do_in): Fix mask operations.

diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc
index b6b6358..b60691c 100644
--- a/libstdc++-v3/src/c++11/codecvt.cc
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -789,7 +789,7 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end,
 {
   range<const char> from{ __from, __from_end };
   range<char16_t> to{ __to, __to_end };
-  codecvt_mode mode = codecvt_mode(_M_mode | (consume_header|generate_header));
+  codecvt_mode mode = codecvt_mode(_M_mode & (consume_header|generate_header));
 #if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
   mode = codecvt_mode(mode | little_endian);
 #endif
@@ -1268,7 +1268,7 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end,
 {
   range<const char> from{ __from, __from_end };
   range<char16_t> to{ __to, __to_end };
-  codecvt_mode mode = codecvt_mode(_M_mode | (consume_header|generate_header));
+  codecvt_mode mode = codecvt_mode(_M_mode & (consume_header|generate_header));
 #if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
   mode = codecvt_mode(mode | little_endian);
 #endif

Reply via email to