public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3 PATCH] PR libstdc++/80034
@ 2017-03-13 18:58 Ville Voutilainen
  2017-03-13 19:37 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Ville Voutilainen @ 2017-03-13 18:58 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

All branches tested on Linux-x64.

Changelogs for trunk, gcc-6-branch, gcc-5-branch (the last two are identical, as
are probably their patches).

2017-03-13  Ville Voutilainen  <ville.voutilainen@gmail.com>

    PR libstdc++/80034
    * include/bits/list.tcc (merge(list&&)): Use const for the size_t
    in the catch-block.
    (merge(list&&, _StrictWeakOrdering)): Likewise.
    * testsuite/23_containers/list/operations/80034.cc: New.

2017-03-13  Ville Voutilainen  <ville.voutilainen@gmail.com>

    PR libstdc++/80034
    * include/bits/list.tcc (merge(list&&)): Use const for the size_t
    in the function and in the catch-block, qualify uses of std::distance.
    (merge(list&&, _StrictWeakOrdering)): Likewise.
    * testsuite/23_containers/list/operations/80034.cc: New.

2017-03-13  Ville Voutilainen  <ville.voutilainen@gmail.com>

    PR libstdc++/80034
    * include/bits/list.tcc (merge(list&&)): Use const for the size_t
    in the function and in the catch-block, qualify uses of std::distance.
    (merge(list&&, _StrictWeakOrdering)): Likewise.
    * testsuite/23_containers/list/operations/80034.cc: New.

[-- Attachment #2: 80034_trunk.diff --]
[-- Type: text/plain, Size: 2110 bytes --]

diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index 9623a13..fcb8353 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -405,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  }
 	  __catch(...)
 	    {
-	      size_t __dist = std::distance(__first2, __last2);
+	      const size_t __dist = std::distance(__first2, __last2);
 	      this->_M_inc_size(__orig_size - __dist);
 	      __x._M_set_size(__dist);
 	      __throw_exception_again;
@@ -453,7 +453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	      }
 	    __catch(...)
 	      {
-		size_t __dist = std::distance(__first2, __last2);
+		const size_t __dist = std::distance(__first2, __last2);
 		this->_M_inc_size(__orig_size - __dist);
 		__x._M_set_size(__dist);
 		__throw_exception_again;
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
new file mode 100644
index 0000000..5c3decd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
@@ -0,0 +1,32 @@
+// { dg-do compile }
+// Copyright (C) 2017 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
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+
+namespace X {
+  struct Y { };
+  bool operator<(Y, Y) { return false; }
+  template<typename T>
+    void distance(T, T) { }
+}
+
+int main()
+{
+  std::list<X::Y> l;
+  l.sort();
+}

[-- Attachment #3: 80034_gcc6.diff --]
[-- Type: text/plain, Size: 2762 bytes --]

diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index 81b8be2..81f6f0a 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -386,7 +386,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  iterator __last1 = end();
 	  iterator __first2 = __x.begin();
 	  iterator __last2 = __x.end();
-	  size_t __orig_size = __x.size();
+	  const size_t __orig_size = __x.size();
 	  __try {
 	    while (__first1 != __last1 && __first2 != __last2)
 	      if (*__first2 < *__first1)
@@ -405,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  }
 	  __catch(...)
 	    {
-	      size_t __dist = distance(__first2, __last2);
+	      const size_t __dist = std::distance(__first2, __last2);
 	      this->_M_inc_size(__orig_size - __dist);
 	      __x._M_set_size(__dist);
 	      __throw_exception_again;
@@ -433,7 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	    iterator __last1 = end();
 	    iterator __first2 = __x.begin();
 	    iterator __last2 = __x.end();
-	    size_t __orig_size = __x.size();
+	    const size_t __orig_size = __x.size();
 	    __try
 	      {
 		while (__first1 != __last1 && __first2 != __last2)
@@ -453,7 +453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	      }
 	    __catch(...)
 	      {
-		size_t __dist = distance(__first2, __last2);
+		const size_t __dist = std::distance(__first2, __last2);
 		this->_M_inc_size(__orig_size - __dist);
 		__x._M_set_size(__dist);
 		__throw_exception_again;
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
new file mode 100644
index 0000000..5c3decd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
@@ -0,0 +1,32 @@
+// { dg-do compile }
+// Copyright (C) 2017 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
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+
+namespace X {
+  struct Y { };
+  bool operator<(Y, Y) { return false; }
+  template<typename T>
+    void distance(T, T) { }
+}
+
+int main()
+{
+  std::list<X::Y> l;
+  l.sort();
+}

[-- Attachment #4: 80034_gcc5.diff --]
[-- Type: text/plain, Size: 2762 bytes --]

diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index b812b19..1a0bb48 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -344,7 +344,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  iterator __last1 = end();
 	  iterator __first2 = __x.begin();
 	  iterator __last2 = __x.end();
-	  size_t __orig_size = __x.size();
+	  const size_t __orig_size = __x.size();
 	  __try {
 	    while (__first1 != __last1 && __first2 != __last2)
 	      if (*__first2 < *__first1)
@@ -363,7 +363,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  }
 	  __catch(...)
 	    {
-	      size_t __dist = distance(__first2, __last2);
+	      const size_t __dist = std::distance(__first2, __last2);
 	      this->_M_inc_size(__orig_size - __dist);
 	      __x._M_set_size(__dist);
 	      __throw_exception_again;
@@ -391,7 +391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	    iterator __last1 = end();
 	    iterator __first2 = __x.begin();
 	    iterator __last2 = __x.end();
-	    size_t __orig_size = __x.size();
+	    const size_t __orig_size = __x.size();
 	    __try
 	      {
 		while (__first1 != __last1 && __first2 != __last2)
@@ -411,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	      }
 	    __catch(...)
 	      {
-		size_t __dist = distance(__first2, __last2);
+		const size_t __dist = std::distance(__first2, __last2);
 		this->_M_inc_size(__orig_size - __dist);
 		__x._M_set_size(__dist);
 		__throw_exception_again;
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
new file mode 100644
index 0000000..5c3decd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc
@@ -0,0 +1,32 @@
+// { dg-do compile }
+// Copyright (C) 2017 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
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+
+namespace X {
+  struct Y { };
+  bool operator<(Y, Y) { return false; }
+  template<typename T>
+    void distance(T, T) { }
+}
+
+int main()
+{
+  std::list<X::Y> l;
+  l.sort();
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [v3 PATCH] PR libstdc++/80034
  2017-03-13 18:58 [v3 PATCH] PR libstdc++/80034 Ville Voutilainen
@ 2017-03-13 19:37 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2017-03-13 19:37 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: libstdc++, gcc-patches

On 13/03/17 20:57 +0200, Ville Voutilainen wrote:
>All branches tested on Linux-x64.
>
>Changelogs for trunk, gcc-6-branch, gcc-5-branch (the last two are identical, as
>are probably their patches).

OK for all three, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-13 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 18:58 [v3 PATCH] PR libstdc++/80034 Ville Voutilainen
2017-03-13 19:37 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).