[patch] fix libstdc++/58764

Jonathan Wakely jwakely@redhat.com
Wed Jan 22 19:53:00 GMT 2014


This undoes the recent change to make the containers' default
constructors explicit, and makes the Debug Mode and Profile Mode
associative containers consistent with normal mode.

The new C++11 containers (forward_list and unordered_*) still have
explicit default constructors, which is probably wrong, but they
weren't changed recently so that isn't a regression and can wait for
the resolution of LWG issue 2193.

Tested x86_64-linux, committed to trunk.

-------------- next part --------------
commit 3bc097d1f765fb323cf9ed61b4096b2a255a4cf8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jan 22 16:41:27 2014 +0000

    	PR libstdc++/58764
    	* include/bits/stl_deque.h (deque::deque(const allocator_type&):
    	Split into separate default constructor and constructor taking
    	allocator.
    	* include/bits/stl_list.h (list::list(const allocator_type&): Likewise.
    	* include/bits/stl_vector.h (vector::vector(const allocator_type&):
    	Likewise.
    	* include/debug/deque (deque::deque(const allocator_type&)): Likewise.
    	* include/debug/list (list::list(const _Allocator&)): Likewise.
    	* include/debug/map.h (map::map(const _Compare&, const _Allocator&)):
    	Likewise.
    	* include/debug/multimap.h
    	(multimap::multimap(const _Compare&, const _Allocator&)): Likewise.
    	* include/debug/set.h (set::set(const _Compare&, const _Allocator&)):
    	Likewise.
    	* include/debug/multiset.h
    	(multiset::multiset(const _Compare&, const _Allocator&)): Likewise.
    	* include/debug/vector (vector::vector(const allocator_type&)):
    	Likewise.
    	* include/profile/deque (deque::deque(const _Allocator&)): Likewise.
    	* include/profile/list (list::list(const _Allocator&)): Likewise.
    	* include/profile/map.h
    	(map::map(const _Compare&, const _Allocator&)): Likewise.
    	* include/profile/multimap.h
    	(multimap::multimap(const _Compare&, const _Allocator&)): Likewise.
    	* include/profile/set.h
    	(set::set(const _Compare&, const _Allocator&)): Likewise.
    	* include/profile/multiset.h
    	(multiset::multiset(const _Compare&, const _Allocator&)): Likewise.
    	* include/profile/vector (vector::vector(const _Allocator&)):
    	Likewise.
    	* testsuite/23_containers/deque/58764.cc: New.
    	* testsuite/23_containers/list/58764.cc: New.
    	* testsuite/23_containers/map/58764.cc: New.
    	* testsuite/23_containers/multimap/58764.cc: New.
    	* testsuite/23_containers/set/58764.cc: New.
    	* testsuite/23_containers/multiset/58764.cc: New.
    	* testsuite/23_containers/vector/58764.cc: New.
    	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
    	Adjust dg-error line number.
    	* testsuite/23_containers/deque/requirements/dr438/
    	constructor_1_neg.cc: Likewise.
    	* testsuite/23_containers/deque/requirements/dr438/
    	constructor_2_neg.cc: Likewise.
    	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
    	Likewise.
    	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
    	Likewise.
    	* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
    	Likewise.
    	* testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc:
    	Likewise.
    	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
    	Likewise.
    	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
    	Likewise.
    	* testsuite/23_containers/vector/requirements/dr438/
    	constructor_1_neg.cc: Likewise.
    	* testsuite/23_containers/vector/requirements/dr438/
    	constructor_2_neg.cc: Likewise.
    	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
    	Likewise.

diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index 996c10f..0f4d0e9 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -781,12 +781,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     public:
       // [23.2.1.1] construct/copy/destroy
       // (assign() and get_allocator() are also listed in this section)
+
+      /**
+       *  @brief  Creates a %deque with no elements.
+       */
+      deque() : _Base() { }
+
       /**
        *  @brief  Creates a %deque with no elements.
        *  @param  __a  An allocator object.
        */
       explicit
-      deque(const allocator_type& __a = allocator_type())
+      deque(const allocator_type& __a)
       : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index b5e6cc8..19bb189 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -526,12 +526,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     public:
       // [23.2.2.1] construct/copy/destroy
       // (assign() and get_allocator() are also listed in this section)
+
+      /**
+       *  @brief  Creates a %list with no elements.
+       */
+      list() _GLIBCXX_NOEXCEPT
+      : _Base() { }
+
       /**
        *  @brief  Creates a %list with no elements.
        *  @param  __a  An allocator object.
        */
       explicit
-      list(const allocator_type& __a = allocator_type()) _GLIBCXX_NOEXCEPT
+      list(const allocator_type& __a) _GLIBCXX_NOEXCEPT
       : _Base(_Node_alloc_type(__a)) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index 2cedd39..14284aa 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -242,12 +242,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     public:
       // [23.2.4.1] construct/copy/destroy
       // (assign() and get_allocator() are also listed in this section)
+
+      /**
+       *  @brief  Creates a %vector with no elements.
+       */
+      vector() _GLIBCXX_NOEXCEPT : _Base() { }
+
       /**
        *  @brief  Creates a %vector with no elements.
        *  @param  __a  An allocator object.
        */
       explicit
-      vector(const allocator_type& __a = allocator_type()) _GLIBCXX_NOEXCEPT
+      vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
       : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index f16d72c..225d06c 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -68,8 +68,11 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.1.1 construct/copy/destroy:
+
+      deque() : _Base() { }
+
       explicit
-      deque(const _Allocator& __a = _Allocator())
+      deque(const _Allocator& __a)
       : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list
index 145f59d..9918bc5 100644
--- a/libstdc++-v3/include/debug/list
+++ b/libstdc++-v3/include/debug/list
@@ -69,8 +69,12 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.2.1 construct/copy/destroy:
+
+      list() _GLIBCXX_NOEXCEPT
+      : _Base() { }
+
       explicit
-      list(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
+      list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
       : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h
index 2367d57..bd68c99 100644
--- a/libstdc++-v3/include/debug/map.h
+++ b/libstdc++-v3/include/debug/map.h
@@ -77,7 +77,10 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.3.1.1 construct/copy/destroy:
-      explicit map(const _Compare& __comp = _Compare(),
+
+      map() : _Base() { }
+
+      explicit map(const _Compare& __comp,
 		   const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h
index 0976573..fad80cc 100644
--- a/libstdc++-v3/include/debug/multimap.h
+++ b/libstdc++-v3/include/debug/multimap.h
@@ -78,7 +78,10 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
 
       // 23.3.1.1 construct/copy/destroy:
-      explicit multimap(const _Compare& __comp = _Compare(),
+
+      multimap() : _Base() { }
+
+      explicit multimap(const _Compare& __comp,
 			const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h
index 5a39ef8..bd555b3 100644
--- a/libstdc++-v3/include/debug/multiset.h
+++ b/libstdc++-v3/include/debug/multiset.h
@@ -77,7 +77,10 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator>  const_reverse_iterator;
 
       // 23.3.3.1 construct/copy/destroy:
-      explicit multiset(const _Compare& __comp = _Compare(),
+
+      multiset() : _Base() { }
+
+      explicit multiset(const _Compare& __comp,
 			const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h
index 8c84f25..f40ecec 100644
--- a/libstdc++-v3/include/debug/set.h
+++ b/libstdc++-v3/include/debug/set.h
@@ -76,7 +76,10 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.3.3.1 construct/copy/destroy:
-      explicit set(const _Compare& __comp = _Compare(),
+
+      set() : _Base() { }
+
+      explicit set(const _Compare& __comp,
 		   const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index 2b750d7..58d98ef 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -76,8 +76,12 @@ namespace __debug
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.4.1 construct/copy/destroy:
+
+      vector() _GLIBCXX_NOEXCEPT
+      : _Base(), _M_guaranteed_capacity(0) { }
+
       explicit
-      vector(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
+      vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
       : _Base(__a), _M_guaranteed_capacity(0) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque
index d6aa6bd..2c4f9cb 100644
--- a/libstdc++-v3/include/profile/deque
+++ b/libstdc++-v3/include/profile/deque
@@ -60,8 +60,12 @@ namespace __profile
       typedef typename _Base::const_pointer         const_pointer;
 
       // 23.2.1.1 construct/copy/destroy:
+
+      deque()
+      : _Base() { }
+
       explicit
-      deque(const _Allocator& __a = _Allocator())
+      deque(const _Allocator& __a)
       : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/profile/list b/libstdc++-v3/include/profile/list
index c893320..87d99a0 100644
--- a/libstdc++-v3/include/profile/list
+++ b/libstdc++-v3/include/profile/list
@@ -64,8 +64,16 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.2.2.1 construct/copy/destroy:
+
+      list() _GLIBCXX_NOEXCEPT
+      : _Base()
+      {
+        __profcxx_list_construct(this); 	// list2slist
+        __profcxx_list_construct2(this); 	// list2vector
+      }
+
       explicit
-      list(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
+      list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
       : _Base(__a) 
       {
         __profcxx_list_construct(this); 	// list2slist
diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h
index 63fb0cb..6a3160b 100644
--- a/libstdc++-v3/include/profile/map.h
+++ b/libstdc++-v3/include/profile/map.h
@@ -67,8 +67,13 @@ namespace __profile
       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
       // 23.3.1.1 construct/copy/destroy:
+
+      map()
+      : _Base()
+      { __profcxx_map_to_unordered_map_construct(this); }
+
       explicit
-      map(const _Compare& __comp = _Compare(),
+      map(const _Compare& __comp,
 	  const _Allocator& __a = _Allocator())
       : _Base(__comp, __a)
       { __profcxx_map_to_unordered_map_construct(this); }
diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h
index 4a703ce3..5ba5355 100644
--- a/libstdc++-v3/include/profile/multimap.h
+++ b/libstdc++-v3/include/profile/multimap.h
@@ -68,7 +68,11 @@ namespace __profile
       typedef typename _Base::const_pointer          const_pointer;
 
       // 23.3.1.1 construct/copy/destroy:
-      explicit multimap(const _Compare& __comp = _Compare(),
+
+      multimap()
+      : _Base() { }
+
+      explicit multimap(const _Compare& __comp,
 			const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/profile/multiset.h b/libstdc++-v3/include/profile/multiset.h
index 1719728..8ef6e6b 100644
--- a/libstdc++-v3/include/profile/multiset.h
+++ b/libstdc++-v3/include/profile/multiset.h
@@ -68,7 +68,11 @@ namespace __profile
       typedef typename _Base::const_pointer          const_pointer;
 
       // 23.3.3.1 construct/copy/destroy:
-      explicit multiset(const _Compare& __comp = _Compare(),
+
+      multiset()
+      : _Base() { }
+
+      explicit multiset(const _Compare& __comp,
 			const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/profile/set.h b/libstdc++-v3/include/profile/set.h
index 3b8fd55..05fbeb9 100644
--- a/libstdc++-v3/include/profile/set.h
+++ b/libstdc++-v3/include/profile/set.h
@@ -68,7 +68,11 @@ namespace __profile
       typedef typename _Base::const_pointer         const_pointer;
 
       // 23.3.3.1 construct/copy/destroy:
-      explicit set(const _Compare& __comp = _Compare(),
+
+      set()
+      : _Base() { }
+
+      explicit set(const _Compare& __comp,
 		   const _Allocator& __a = _Allocator())
       : _Base(__comp, __a) { }
 
diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector
index a286ac5..5c2c621 100644
--- a/libstdc++-v3/include/profile/vector
+++ b/libstdc++-v3/include/profile/vector
@@ -77,8 +77,16 @@ namespace __profile
       _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
 
       // 23.2.4.1 construct/copy/destroy:
+
+      vector() _GLIBCXX_NOEXCEPT
+      : _Base()
+      {
+        __profcxx_vector_construct(this, this->capacity());
+        __profcxx_vector_construct2(this);
+      }
+
       explicit
-      vector(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
+      vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
       : _Base(__a)
       {
         __profcxx_vector_construct(this, this->capacity());
diff --git a/libstdc++-v3/testsuite/23_containers/deque/58764.cc b/libstdc++-v3/testsuite/23_containers/deque/58764.cc
new file mode 100644
index 0000000..a1056aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <deque>
+
+void test01()
+{
+  std::deque<int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
index b4d2c80..4de8f2d 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1758 }
+// { dg-error "no matching" "" { target *-*-* } 1764 }
 
 #include <deque>
 
diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
index bfa6692..41f2905 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1691 }
+// { dg-error "no matching" "" { target *-*-* } 1697 }
 
 #include <deque>
 
diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
index 9a05437..f77b126 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1691 }
+// { dg-error "no matching" "" { target *-*-* } 1697 }
 
 #include <deque>
 #include <utility>
diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
index d2bb0fb..e7d5b1e 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1842 }
+// { dg-error "no matching" "" { target *-*-* } 1848 }
 
 #include <deque>
 
diff --git a/libstdc++-v3/testsuite/23_containers/list/58764.cc b/libstdc++-v3/testsuite/23_containers/list/58764.cc
new file mode 100644
index 0000000..c523e02
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <list>
+
+void test01()
+{
+  std::list<int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
index 6dbf143..fed7829 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1646 }
+// { dg-error "no matching" "" { target *-*-* } 1653 }
 
 #include <list>
 
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
index 915ecf4..f5eae4f 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1598 }
+// { dg-error "no matching" "" { target *-*-* } 1605 }
 
 #include <list>
 
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
index 5c94805..e0fbe97 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1598 }
+// { dg-error "no matching" "" { target *-*-* } 1605 }
 
 #include <list>
 #include <utility>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
index 30ea0c4..3904624 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1598 }
+// { dg-error "no matching" "" { target *-*-* } 1605 }
 
 #include <list>
 
diff --git a/libstdc++-v3/testsuite/23_containers/map/58764.cc b/libstdc++-v3/testsuite/23_containers/map/58764.cc
new file mode 100644
index 0000000..31e0966
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <map>
+
+void test01()
+{
+  std::map<int, int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/58764.cc b/libstdc++-v3/testsuite/23_containers/multimap/58764.cc
new file mode 100644
index 0000000..4e85116
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <map>
+
+void test01()
+{
+  std::multimap<int, int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/58764.cc b/libstdc++-v3/testsuite/23_containers/multiset/58764.cc
new file mode 100644
index 0000000..f827923
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multiset/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <set>
+
+void test01()
+{
+  std::multiset<int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/58764.cc b/libstdc++-v3/testsuite/23_containers/set/58764.cc
new file mode 100644
index 0000000..9a2ae3a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/58764.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <set>
+
+void test01()
+{
+  std::set<int> a = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/58764.cc b/libstdc++-v3/testsuite/23_containers/vector/58764.cc
new file mode 100644
index 0000000..6a9823c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/58764.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2014 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/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/58764
+
+#include <vector>
+
+void test01()
+{
+  std::vector<int> a = {};
+  std::vector<bool> b = {};
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
index 158a902..cfbe734 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1306 }
+// { dg-error "no matching" "" { target *-*-* } 1312 }
 
 #include <vector>
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
index cf186eb..88b6e0e 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1232 }
+// { dg-error "no matching" "" { target *-*-* } 1238 }
 
 #include <vector>
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
index cbbc1d3..94cc4ba 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1232 }
+// { dg-error "no matching" "" { target *-*-* } 1238 }
 
 #include <vector>
 #include <utility>
diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
index 8471a64..de61175 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1347 }
+// { dg-error "no matching" "" { target *-*-* } 1353 }
 
 #include <vector>
 

commit 422470c189acc42cfe7292e6f08a60412213334d
Author: vmakarov <vmakarov@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Jan 22 19:38:47 2014 +0000

    2014-01-22  Vladimir Makarov  <vmakarov@redhat.com>
    
    	PR rtl-optimization/59477
    	* lra-constraints.c (inherit_in_ebb): Process call for living hard
    	regs.  Update reloads_num and potential_reload_hard_regs for all
    	insns.
    
    2014-01-22  Vladimir Makarov  <vmakarov@redhat.com>
    
    	PR rtl-optimization/59477
    	* g++.dg/pr59477.C: New.
    
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206938 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index dc5e59a..7454229 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -5007,7 +5007,7 @@ static bool
 inherit_in_ebb (rtx head, rtx tail)
 {
   int i, src_regno, dst_regno, nregs;
-  bool change_p, succ_p;
+  bool change_p, succ_p, update_reloads_num_p;
   rtx prev_insn, next_usage_insns, set, last_insn;
   enum reg_class cl;
   struct lra_insn_reg *reg;
@@ -5078,6 +5078,7 @@ inherit_in_ebb (rtx head, rtx tail)
 	  src_regno = REGNO (SET_SRC (set));
 	  dst_regno = REGNO (SET_DEST (set));
 	}
+      update_reloads_num_p = true;
       if (src_regno < lra_constraint_new_regno_start
 	  && src_regno >= FIRST_PSEUDO_REGISTER
 	  && reg_renumber[src_regno] < 0
@@ -5086,6 +5087,7 @@ inherit_in_ebb (rtx head, rtx tail)
 	{
 	  /* 'reload_pseudo <- original_pseudo'.  */
 	  reloads_num++;
+	  update_reloads_num_p = false;
 	  succ_p = false;
 	  if (usage_insns[src_regno].check == curr_usage_insns_check
 	      && (next_usage_insns = usage_insns[src_regno].insns) != NULL_RTX)
@@ -5109,6 +5111,7 @@ inherit_in_ebb (rtx head, rtx tail)
 		   = usage_insns[dst_regno].insns) != NULL_RTX)
 	{
 	  reloads_num++;
+	  update_reloads_num_p = false;
 	  /* 'original_pseudo <- reload_pseudo'.  */
 	  if (! JUMP_P (curr_insn)
 	      && inherit_reload_reg (true, dst_regno, cl,
@@ -5297,6 +5300,14 @@ inherit_in_ebb (rtx head, rtx tail)
 		      add_next_usage_insn (src_regno, use_insn, reloads_num);
 		    }
 		}
+	  /* Process call args.  */
+	  if (curr_id->arg_hard_regs != NULL)
+	    for (i = 0; (src_regno = curr_id->arg_hard_regs[i]) >= 0; i++)
+	      if (src_regno < FIRST_PSEUDO_REGISTER)
+		{
+	           SET_HARD_REG_BIT (live_hard_regs, src_regno);
+	           add_next_usage_insn (src_regno, curr_insn, reloads_num);
+		}
 	  for (i = 0; i < to_inherit_num; i++)
 	    {
 	      src_regno = to_inherit[i].regno;
@@ -5307,6 +5318,26 @@ inherit_in_ebb (rtx head, rtx tail)
 		setup_next_usage_insn (src_regno, curr_insn, reloads_num, false);
 	    }
 	}
+      if (update_reloads_num_p
+	  && NONDEBUG_INSN_P (curr_insn)
+          && (set = single_set (curr_insn)) != NULL_RTX)
+	{
+	  int regno = -1;
+	  if ((REG_P (SET_DEST (set))
+	       && (regno = REGNO (SET_DEST (set))) >= lra_constraint_new_regno_start
+	       && reg_renumber[regno] < 0
+	       && (cl = lra_get_allocno_class (regno)) != NO_REGS)
+	      || (REG_P (SET_SRC (set))
+	          && (regno = REGNO (SET_SRC (set))) >= lra_constraint_new_regno_start
+	          && reg_renumber[regno] < 0
+	          && (cl = lra_get_allocno_class (regno)) != NO_REGS))
+	    {
+	      reloads_num++;
+	      if (hard_reg_set_subset_p (reg_class_contents[cl], live_hard_regs))
+		IOR_HARD_REG_SET (potential_reload_hard_regs,
+	                          reg_class_contents[cl]);
+	    }
+	}
       /* We reached the start of the current basic block.  */
       if (prev_insn == NULL_RTX || prev_insn == PREV_INSN (head)
 	  || BLOCK_FOR_INSN (prev_insn) != curr_bb)
diff --git a/gcc/testsuite/g++.dg/pr59477.C b/gcc/testsuite/g++.dg/pr59477.C
new file mode 100644
index 0000000..788c751
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr59477.C
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct A
+{
+  unsigned *a, b;
+  A (unsigned x) : a (), b (x) {}
+};
+
+struct B
+{
+  B (int);
+  B (const B &) {}
+};
+
+B bar (B, B, A);
+int v;
+
+void
+foo ()
+{
+  B c = 0;
+  bar (c, c, A (1ULL << v));
+}


More information about the Gcc-patches mailing list