diff mbox

Fix PR80183 : _M_color not moved

Message ID 20170326095438.GA299@x4
State New
Headers show

Commit Message

Markus Trippelsdorf March 26, 2017, 9:54 a.m. UTC
clang-format stopped working when compiled with gcc-7. 
It turned out that an uninitialized _M_color is responsible.

The fix is easy, just copy _M_color in the move case, too.

Tested on ppc64le.
OK for trunk?
Thanks.

	PR libstdc++/80183
	* include/bits/stl_tree.h:
	(_Rb_tree_header::_M_move_data(_Rb_tree_header&)): Also save _M_color.

Comments

Jonathan Wakely March 26, 2017, 12:23 p.m. UTC | #1
On 26/03/17 11:54 +0200, Markus Trippelsdorf wrote:
>clang-format stopped working when compiled with gcc-7.
>It turned out that an uninitialized _M_color is responsible.
>
>The fix is easy, just copy _M_color in the move case, too.
>
>Tested on ppc64le.
>OK for trunk?

OK, thanks.

A reduced testcase would be nice, in case we ever get the ability to
run the testsuite under valgrind and/or ubsan. Please commit the fix
anyway though, a testcase can come later.

>Thanks.
>
>	PR libstdc++/80183
>	* include/bits/stl_tree.h:
>	(_Rb_tree_header::_M_move_data(_Rb_tree_header&)): Also save _M_color.
>
>diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
>index cbcf7f2606f..ce7ecdaa87a 100644
>--- a/libstdc++-v3/include/bits/stl_tree.h
>+++ b/libstdc++-v3/include/bits/stl_tree.h
>@@ -192,6 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>     void
>     _M_move_data(_Rb_tree_header& __from)
>     {
>+      _M_header._M_color = __from._M_header._M_color;
>       _M_header._M_parent = __from._M_header._M_parent;
>       _M_header._M_left = __from._M_header._M_left;
>       _M_header._M_right = __from._M_header._M_right;
>-- 
>Markus
diff mbox

Patch

diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index cbcf7f2606f..ce7ecdaa87a 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -192,6 +192,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     void
     _M_move_data(_Rb_tree_header& __from)
     {
+      _M_header._M_color = __from._M_header._M_color;
       _M_header._M_parent = __from._M_header._M_parent;
       _M_header._M_left = __from._M_header._M_left;
       _M_header._M_right = __from._M_header._M_right;