Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-05-26 Thread Jonathan Wakely

On 26/05/16 14:02 +0200, Christophe Lyon wrote:

I've seen you've backported the main patch to the gcc-6 branch, you
forgot to add the follow-up "Add dg-require-filesystem-ts directive to
test".


And likewise for the gcc-5 branch.


Both fixed now, sorry about that, again.



Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-05-26 Thread Christophe Lyon
On 26 May 2016 at 13:58, Christophe Lyon  wrote:
> On 5 May 2016 at 12:12, Jonathan Wakely  wrote:
>> On 04/05/16 17:19 +0100, Andre Vieira (lists) wrote:
>>>
>>> On 20/04/16 18:40, Jonathan Wakely wrote:

 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.


>>> Hi Jonathan,
>>>
>>> We are seeing experimental/filesystem/path/native/string.cc fail on
>>> baremetal targets. I'm guessing this is missing a
>>> 'dg-require-filesystem-ts', as seen on other tests like
>>> experimental/filesystem/path/modifiers/swap.cc.
>>>
>>> Cheers,
>>> Andre
>>
>>
>> Sorry about that, I've committed the missing directive.
>>
>>
> Hi,
>
> I've seen you've backported the main patch to the gcc-6 branch, you
> forgot to add the follow-up "Add dg-require-filesystem-ts directive to
> test".
>
And likewise for the gcc-5 branch.

> Christophe


Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-05-26 Thread Christophe Lyon
On 5 May 2016 at 12:12, Jonathan Wakely  wrote:
> On 04/05/16 17:19 +0100, Andre Vieira (lists) wrote:
>>
>> On 20/04/16 18:40, Jonathan Wakely wrote:
>>>
>>> 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.
>>>
>>>
>> Hi Jonathan,
>>
>> We are seeing experimental/filesystem/path/native/string.cc fail on
>> baremetal targets. I'm guessing this is missing a
>> 'dg-require-filesystem-ts', as seen on other tests like
>> experimental/filesystem/path/modifiers/swap.cc.
>>
>> Cheers,
>> Andre
>
>
> Sorry about that, I've committed the missing directive.
>
>
Hi,

I've seen you've backported the main patch to the gcc-6 branch, you
forgot to add the follow-up "Add dg-require-filesystem-ts directive to
test".

Christophe


Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-05-05 Thread Jonathan Wakely

On 04/05/16 17:19 +0100, Andre Vieira (lists) wrote:

On 20/04/16 18:40, Jonathan Wakely wrote:

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.



Hi Jonathan,

We are seeing experimental/filesystem/path/native/string.cc fail on
baremetal targets. I'm guessing this is missing a
'dg-require-filesystem-ts', as seen on other tests like
experimental/filesystem/path/modifiers/swap.cc.

Cheers,
Andre


Sorry about that, I've committed the missing directive.


commit 775381d7e53d5a68a2725b6b72f081d254d9380b
Author: Jonathan Wakely 
Date:   Thu May 5 10:42:35 2016 +0100

Add dg-require-filesystem-ts directive to test

	* testsuite/experimental/filesystem/path/native/string.cc: Add
	dg-require-filesystem-ts directive.

diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc
index 05ff57c..e56fda7 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-options "-std=gnu++11 -lstdc++fs" }
+// { dg-require-filesystem-ts "" }
 
 #include 
 #include 


Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-05-04 Thread Andre Vieira (lists)
On 20/04/16 18:40, Jonathan Wakely wrote:
> 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.
> 
> 
Hi Jonathan,

We are seeing experimental/filesystem/path/native/string.cc fail on
baremetal targets. I'm guessing this is missing a
'dg-require-filesystem-ts', as seen on other tests like
experimental/filesystem/path/modifiers/swap.cc.

Cheers,
Andre


Re: [patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-04-20 Thread Jonathan Wakely

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 
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::do_in,
	__codecvt_utf8_utf16_base::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 from{ __from, __from_end };
   range 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 from{ __from, __from_end };
   range 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


[patch] libstdc++/69703 ignore endianness in codecvt_utf8

2016-04-19 Thread Jonathan Wakely

This was reported as a bug in the Filesystem library, but it's
actually a problem in the codecvt_utf8 facet that it uses.

Tested x86_64-linux, committed to trunk.


commit 7f3a547a9e80556030e77ac090e2ad8e04e44abc
Author: Jonathan Wakely 
Date:   Tue Apr 19 18:32:17 2016 +0100

libstdc++/69703 ignore endianness in codecvt_utf8

	PR libstdc++/69703
	* src/c++11/codecvt.cc (__codecvt_utf8_base::do_in)):
	Override endianness bit in mode.
	* testsuite/22_locale/codecvt/codecvt_utf8/69703.cc: New test.
	* testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc: Test
	that little_endian mode is ignored.
	* testsuite/experimental/filesystem/path/native/string.cc: New test.

diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc
index 327beb6..b6b6358 100644
--- a/libstdc++-v3/src/c++11/codecvt.cc
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -789,7 +789,11 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end,
 {
   range from{ __from, __from_end };
   range to{ __to, __to_end };
-  auto res = ucs2_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 = ucs2_in(from, to, _M_maxcode, mode);
   __from_next = from.next;
   __to_next = to.next;
   return res;
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc
new file mode 100644
index 000..745d2c2
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc
@@ -0,0 +1,103 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++11" }
+
+#include 
+#include 
+
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  const char out[] = "abc";
+  char16_t in[4];
+  std::codecvt_utf8 cvt;
+  std::mbstate_t st;
+  const char* no;
+  char16_t* ni;
+  auto res = cvt.in(st, out, out+3, no, in, in+3, ni);
+  VERIFY( res == std::codecvt_base::ok );
+  VERIFY( in[0] == u'a' );
+  VERIFY( in[1] == u'b' );
+  VERIFY( in[2] == u'c' );
+}
+
+void
+test02()
+{
+  bool test __attribute__((unused)) = true;
+
+  const char out[] = "abc";
+  char16_t in[4];
+  std::codecvt_utf8 cvt;
+  std::mbstate_t st;
+  const char* no;
+  char16_t* ni;
+  auto res = cvt.in(st, out, out+3, no, in, in+3, ni);
+  VERIFY( res == std::codecvt_base::ok );
+  VERIFY( in[0] == u'a' );
+  VERIFY( in[1] == u'b' );
+  VERIFY( in[2] == u'c' );
+}
+
+void
+test03()
+{
+  bool test __attribute__((unused)) = true;
+
+  const char out[] = "abc";
+  char32_t in[4];
+  std::codecvt_utf8 cvt;
+  std::mbstate_t st;
+  const char* no;
+  char32_t* ni;
+  auto res = cvt.in(st, out, out+3, no, in, in+3, ni);
+  VERIFY( res == std::codecvt_base::ok );
+  VERIFY( in[0] == U'a' );
+  VERIFY( in[1] == U'b' );
+  VERIFY( in[2] == U'c' );
+}
+
+
+void
+test04()
+{
+  bool test __attribute__((unused)) = true;
+
+  const char out[] = "abc";
+  char32_t in[4];
+  std::codecvt_utf8 cvt;
+  std::mbstate_t st;
+  const char* no;
+  char32_t* ni;
+  auto res = cvt.in(st, out, out+3, no, in, in+3, ni);
+  VERIFY( res == std::codecvt_base::ok );
+  VERIFY( in[0] == U'a' );
+  VERIFY( in[1] == U'b' );
+  VERIFY( in[2] == U'c' );
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc
index 05e5bc6..49b750f 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc
@@ -45,8 +45,35 @@ test01()
   VERIFY( buf[3] == utf16[3] );
 }
 
+void
+test02()
+{
+  // Endianness flag should make no difference.
+  std::codecvt_utf8_utf16 cvt;
+  char16_t utf16[] = u"\ub098\ub294\ud0dc\uc624";
+  const char16_t* nf16;
+  char utf8[16];
+  char* nt8;
+  std::mbstate_t st{};
+  auto res = cvt.out(st, utf16, utf16+4, nf16, utf8, utf8+16,