Patchwork [v3] Fix libstdc++/50118

login
register
mail settings
Submitter Paolo Carlini
Date Aug. 29, 2011, 1:42 p.m.
Message ID <4E5B9730.4080104@oracle.com>
Download mbox | patch
Permalink /patch/112053/
State New
Headers show

Comments

Paolo Carlini - Aug. 29, 2011, 1:42 p.m.
Hi,

tested x86_64-linux, committed to mainline.

Thanks,
Paolo.

///////////////////////////
2011-08-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/50118
	* include/bits/stl_list.h (_List_base<>::
	_List_base(const allocator_type&)): Remove.
	(_List_base<>::_List_base(const _Node_alloc_type&)): Add.
	(list<>:list(const allocator_type&), list(size_type, const
	value_type&, const allocator_type&),
	list(initializer_list<, const allocator_type&),
	list(_InputIterator, _InputIterator, const allocator_type&),
	insert(iterator, size_type, const value_type&),
	insert(iterator, _InputIterator, _InputIterator)): Adjust.
	* include/bits/stl_tree.h (_Rb_tree<>::_Rb_tree(const _Compare&,
	const allocator_type&)): Fix.
	* include/bits/stl_map.h (map<>::map(const _Compare&,
 	const allocator_type&), map(initializer_list<>,
	const _Compare&, const allocator_type&), map(_InputIterator,
	_InputIterator, const _Compare&, const allocator_type&),
	get_allocator): Adjust.
	* include/bits/stl_set.h (set<>::set(const _Compare&,
 	const allocator_type&), set(initializer_list<>,
	const _Compare&, const allocator_type&), set(_InputIterator,
	_InputIterator, const _Compare&, const allocator_type&),
	get_allocator): Likewise.
	* include/bits/stl_multimap.h (multimap<>::multimap(const _Compare&,
 	const allocator_type&), multimap(initializer_list<>,
	const _Compare&, const allocator_type&), multimap(_InputIterator,
	_InputIterator, const _Compare&, const allocator_type&),
	get_allocator): Likewise.
	* include/bits/stl_multiset.h (multiset<>::multiset(const _Compare&,
 	const allocator_type&), multiset(initializer_list<>,
	const _Compare&, const allocator_type&), multiset(_InputIterator,
	_InputIterator, const _Compare&, const allocator_type&),
	get_allocator): Likewise.
	* include/bits/forward_list.h (_Fwd_list_base<>::
	_Fwd_list_base(const _Alloc&), _Fwd_list_base(const _Fwd_list_base&,
	const _Alloc&), _Fwd_list_base(_Fwd_list_base&&, const _Alloc&)):
	Remove.
	(_Fwd_list_base<>::_Fwd_list_base(const _Node_alloc_type&),
	_Fwd_list_base(const _Fwd_list_base&,
	const _Node_alloc_type&), _Fwd_list_base(_Fwd_list_base&&,
	const _Node_alloc_type&)): Add.
	(forward_list<>::forward_list(const _Alloc&),
	forward_list(const forward_list&, const _Alloc&),
	forward_list(forward_list&&, const _Alloc&),
	forward_list(size_type, const _Tp&, const _Alloc&),
	forward_list(_InputIterator, _InputIterator, const _Alloc&),
	forward_list(std::initializer_list<>, const _Alloc&),
	get_allocator): Adjust.
	* include/bits/forward_list.tcc
	* testsuite/util/testsuite_allocator.h (ExplicitConsAlloc): Add.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/5.cc: New.
	* testsuite/23_containers/multimap/requirements/
	explicit_instantiation/5.cc: Likewise.
	* testsuite/23_containers/multimap/requirements/
	explicit_instantiation/5_c++0x.cc: Likewise.
	* testsuite/23_containers/set/requirements/explicit_instantiation/
	5.cc: Likewise.
	* testsuite/23_containers/set/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/5.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/5.cc: Likewise.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/5.cc: Likewise.
	testsuite/23_containers/multiset/requirements/explicit_instantiation/
	5.cc: Likewise.
	* testsuite/23_containers/multiset/requirements/
	explicit_instantiation/5_c++0x.cc: Likewise.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	5.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/5.cc: Likewise.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	5.cc: Likewise.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	assign_neg.cc: Adjust dg-error line number.
	* testsuite/23_containers/forward_list/requirements/dr438/
	insert_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/insert_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.

Patch

Index: include/bits/stl_list.h
===================================================================
--- include/bits/stl_list.h	(revision 178206)
+++ include/bits/stl_list.h	(working copy)
@@ -359,7 +359,7 @@ 
       : _M_impl()
       { _M_init(); }
 
-      _List_base(const allocator_type& __a)
+      _List_base(const _Node_alloc_type& __a)
       : _M_impl(__a)
       { _M_init(); }
 
@@ -441,6 +441,7 @@ 
 
       typedef _List_base<_Tp, _Alloc>                    _Base;
       typedef typename _Base::_Tp_alloc_type		 _Tp_alloc_type;
+      typedef typename _Base::_Node_alloc_type		 _Node_alloc_type;
 
     public:
       typedef _Tp                                        value_type;
@@ -525,7 +526,7 @@ 
        */
       explicit
       list(const allocator_type& __a)
-      : _Base(__a) { }
+      : _Base(_Node_alloc_type(__a)) { }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       /**
@@ -550,7 +551,7 @@ 
        */
       list(size_type __n, const value_type& __value,
 	   const allocator_type& __a = allocator_type())
-      : _Base(__a)
+      : _Base(_Node_alloc_type(__a))
       { _M_fill_initialize(__n, __value); }
 #else
       /**
@@ -564,7 +565,7 @@ 
       explicit
       list(size_type __n, const value_type& __value = value_type(),
 	   const allocator_type& __a = allocator_type())
-      : _Base(__a)
+      : _Base(_Node_alloc_type(__a))
       { _M_fill_initialize(__n, __value); }
 #endif
 
@@ -600,7 +601,7 @@ 
        */
       list(initializer_list<value_type> __l,
            const allocator_type& __a = allocator_type())
-      : _Base(__a)
+      : _Base(_Node_alloc_type(__a))
       { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
 #endif
 
@@ -617,7 +618,7 @@ 
       template<typename _InputIterator>
         list(_InputIterator __first, _InputIterator __last,
 	     const allocator_type& __a = allocator_type())
-        : _Base(__a)
+	: _Base(_Node_alloc_type(__a))
         { 
 	  // Check whether it's an integral type.  If so, it's not an iterator.
 	  typedef typename std::__is_integer<_InputIterator>::__type _Integral;
@@ -1100,8 +1101,8 @@ 
        */
       void
       insert(iterator __position, size_type __n, const value_type& __x)
-      {  
-	list __tmp(__n, __x, _M_get_Node_allocator());
+      {
+	list __tmp(__n, __x, get_allocator());
 	splice(__position, __tmp);
       }
 
@@ -1123,7 +1124,7 @@ 
         insert(iterator __position, _InputIterator __first,
 	       _InputIterator __last)
         {
-	  list __tmp(__first, __last, _M_get_Node_allocator());
+	  list __tmp(__first, __last, get_allocator());
 	  splice(__position, __tmp);
 	}
 
Index: include/bits/stl_map.h
===================================================================
--- include/bits/stl_map.h	(revision 178206)
+++ include/bits/stl_map.h	(working copy)
@@ -160,7 +160,7 @@ 
       explicit
       map(const _Compare& __comp,
 	  const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a) { }
+      : _M_t(__comp, _Pair_alloc_type(__a)) { }
 
       /**
        *  @brief  %Map copy constructor.
@@ -198,7 +198,7 @@ 
       map(initializer_list<value_type> __l,
 	  const _Compare& __comp = _Compare(),
 	  const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a)
+      : _M_t(__comp, _Pair_alloc_type(__a))
       { _M_t._M_insert_unique(__l.begin(), __l.end()); }
 #endif
 
@@ -233,7 +233,7 @@ 
         map(_InputIterator __first, _InputIterator __last,
 	    const _Compare& __comp,
 	    const allocator_type& __a = allocator_type())
-	: _M_t(__comp, __a)
+	: _M_t(__comp, _Pair_alloc_type(__a))
         { _M_t._M_insert_unique(__first, __last); }
 
       // FIXME There is no dtor declared, but we should have something
@@ -300,7 +300,7 @@ 
       /// Get a copy of the memory allocation object.
       allocator_type
       get_allocator() const _GLIBCXX_NOEXCEPT
-      { return _M_t.get_allocator(); }
+      { return allocator_type(_M_t.get_allocator()); }
 
       // iterators
       /**
Index: include/bits/stl_set.h
===================================================================
--- include/bits/stl_set.h	(revision 178206)
+++ include/bits/stl_set.h	(working copy)
@@ -146,7 +146,7 @@ 
       explicit
       set(const _Compare& __comp,
 	  const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a) { }
+      : _M_t(__comp, _Key_alloc_type(__a)) { }
 
       /**
        *  @brief  Builds a %set from a range.
@@ -179,8 +179,8 @@ 
 	set(_InputIterator __first, _InputIterator __last,
 	    const _Compare& __comp,
 	    const allocator_type& __a = allocator_type())
-	: _M_t(__comp, __a)
-	{ _M_t._M_insert_unique(__first, __last); }
+	: _M_t(__comp, _Key_alloc_type(__a))
+        { _M_t._M_insert_unique(__first, __last); }
 
       /**
        *  @brief  %Set copy constructor.
@@ -217,7 +217,7 @@ 
       set(initializer_list<value_type> __l,
 	  const _Compare& __comp = _Compare(),
 	  const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a)
+      : _M_t(__comp, _Key_alloc_type(__a))
       { _M_t._M_insert_unique(__l.begin(), __l.end()); }
 #endif
 
@@ -286,7 +286,7 @@ 
       ///  Returns the allocator object with which the %set was constructed.
       allocator_type
       get_allocator() const _GLIBCXX_NOEXCEPT
-      { return _M_t.get_allocator(); }
+      { return allocator_type(_M_t.get_allocator()); }
 
       /**
        *  Returns a read-only (constant) iterator that points to the first
Index: include/bits/forward_list.h
===================================================================
--- include/bits/forward_list.h	(revision 178206)
+++ include/bits/forward_list.h	(working copy)
@@ -314,12 +314,12 @@ 
       _Fwd_list_base()
       : _M_impl() { }
 
-      _Fwd_list_base(const _Alloc& __a)
+      _Fwd_list_base(const _Node_alloc_type& __a)
       : _M_impl(__a) { }
 
-      _Fwd_list_base(const _Fwd_list_base& __lst, const _Alloc& __a);
+      _Fwd_list_base(const _Fwd_list_base& __lst, const _Node_alloc_type& __a);
 
-      _Fwd_list_base(_Fwd_list_base&& __lst, const _Alloc& __a)
+      _Fwd_list_base(_Fwd_list_base&& __lst, const _Node_alloc_type& __a)
       : _M_impl(__a)
       {
 	this->_M_impl._M_head._M_next = __lst._M_impl._M_head._M_next;
@@ -416,6 +416,7 @@ 
       typedef _Fwd_list_node<_Tp>                          _Node;
       typedef _Fwd_list_node_base                          _Node_base;
       typedef typename _Base::_Tp_alloc_type               _Tp_alloc_type;
+      typedef typename _Base::_Node_alloc_type             _Node_alloc_type;
 
     public:
       // types:
@@ -439,7 +440,7 @@ 
        */
       explicit
       forward_list(const _Alloc& __al = _Alloc())
-      : _Base(__al)
+      : _Base(_Node_alloc_type(__al))
       { }
 
       /**
@@ -448,7 +449,7 @@ 
        *  @param  __al    An allocator object.
        */
       forward_list(const forward_list& __list, const _Alloc& __al)
-      : _Base(__list, __al)
+      : _Base(__list, _Node_alloc_type(__al))
       { }
 
       /**
@@ -457,7 +458,7 @@ 
        *  @param  __al    An allocator object.
        */
       forward_list(forward_list&& __list, const _Alloc& __al)
-      : _Base(std::move(__list), __al)
+      : _Base(std::move(__list), _Node_alloc_type(__al))
       { }
 
       /**
@@ -483,7 +484,7 @@ 
        */
       forward_list(size_type __n, const _Tp& __value,
                    const _Alloc& __al = _Alloc())
-      : _Base(__al)
+      : _Base(_Node_alloc_type(__al))
       { _M_fill_initialize(__n, __value); }
 
       /**
@@ -499,7 +500,7 @@ 
       template<typename _InputIterator>
         forward_list(_InputIterator __first, _InputIterator __last,
                      const _Alloc& __al = _Alloc())
-        : _Base(__al)
+	: _Base(_Node_alloc_type(__al))
         {
           // Check whether it's an integral type.  If so, it's not an iterator.
           typedef typename std::__is_integer<_InputIterator>::__type _Integral;
@@ -540,7 +541,7 @@ 
        */
       forward_list(std::initializer_list<_Tp> __il,
                    const _Alloc& __al = _Alloc())
-      : _Base(__al)
+      : _Base(_Node_alloc_type(__al))
       { _M_initialize_dispatch(__il.begin(), __il.end(), __false_type()); }
 
       /**
@@ -649,7 +650,7 @@ 
       /// Get a copy of the memory allocation object.
       allocator_type
       get_allocator() const noexcept
-      { return this->_M_get_Node_allocator(); }
+      { return allocator_type(this->_M_get_Node_allocator()); }
 
       // 23.2.3.2 iterators:
 
Index: include/bits/stl_multimap.h
===================================================================
--- include/bits/stl_multimap.h	(revision 178206)
+++ include/bits/stl_multimap.h	(working copy)
@@ -158,7 +158,7 @@ 
       explicit
       multimap(const _Compare& __comp,
 	       const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a) { }
+      : _M_t(__comp, _Pair_alloc_type(__a)) { }
 
       /**
        *  @brief  %Multimap copy constructor.
@@ -195,7 +195,7 @@ 
       multimap(initializer_list<value_type> __l,
 	       const _Compare& __comp = _Compare(),
 	       const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a)
+      : _M_t(__comp, _Pair_alloc_type(__a))
       { _M_t._M_insert_equal(__l.begin(), __l.end()); }
 #endif
 
@@ -228,7 +228,7 @@ 
         multimap(_InputIterator __first, _InputIterator __last,
 		 const _Compare& __comp,
 		 const allocator_type& __a = allocator_type())
-        : _M_t(__comp, __a)
+	: _M_t(__comp, _Pair_alloc_type(__a))
         { _M_t._M_insert_equal(__first, __last); }
 
       // FIXME There is no dtor declared, but we should have something generated
@@ -295,7 +295,7 @@ 
       /// Get a copy of the memory allocation object.
       allocator_type
       get_allocator() const _GLIBCXX_NOEXCEPT 
-      { return _M_t.get_allocator(); }
+      { return allocator_type(_M_t.get_allocator()); }
 
       // iterators
       /**
Index: include/bits/stl_multiset.h
===================================================================
--- include/bits/stl_multiset.h	(revision 178206)
+++ include/bits/stl_multiset.h	(working copy)
@@ -139,7 +139,7 @@ 
       explicit
       multiset(const _Compare& __comp,
 	       const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a) { }
+      : _M_t(__comp, _Key_alloc_type(__a)) { }
 
       /**
        *  @brief  Builds a %multiset from a range.
@@ -170,7 +170,7 @@ 
         multiset(_InputIterator __first, _InputIterator __last,
 		 const _Compare& __comp,
 		 const allocator_type& __a = allocator_type())
-	: _M_t(__comp, __a)
+	: _M_t(__comp, _Key_alloc_type(__a))
         { _M_t._M_insert_equal(__first, __last); }
 
       /**
@@ -208,7 +208,7 @@ 
       multiset(initializer_list<value_type> __l,
 	       const _Compare& __comp = _Compare(),
 	       const allocator_type& __a = allocator_type())
-      : _M_t(__comp, __a)
+      : _M_t(__comp, _Key_alloc_type(__a))
       { _M_t._M_insert_equal(__l.begin(), __l.end()); }
 #endif
 
@@ -278,7 +278,7 @@ 
       ///  Returns the memory allocation object.
       allocator_type
       get_allocator() const _GLIBCXX_NOEXCEPT
-      { return _M_t.get_allocator(); }
+      { return allocator_type(_M_t.get_allocator()); }
 
       /**
        *  Returns a read-only (constant) iterator that points to the first
Index: include/bits/forward_list.tcc
===================================================================
--- include/bits/forward_list.tcc	(revision 178206)
+++ include/bits/forward_list.tcc	(working copy)
@@ -36,7 +36,7 @@ 
 
   template<typename _Tp, typename _Alloc>
     _Fwd_list_base<_Tp, _Alloc>::
-    _Fwd_list_base(const _Fwd_list_base& __lst, const _Alloc& __a)
+    _Fwd_list_base(const _Fwd_list_base& __lst, const _Node_alloc_type& __a)
     : _M_impl(__a)
     {
       this->_M_impl._M_head._M_next = 0;
@@ -250,7 +250,7 @@ 
     {
       if (__n)
 	{
-	  forward_list __tmp(__n, __val, this->_M_get_Node_allocator());
+	  forward_list __tmp(__n, __val, get_allocator());
 	  return _M_splice_after(__pos, std::move(__tmp));
 	}
       else
@@ -264,7 +264,7 @@ 
       insert_after(const_iterator __pos,
 		   _InputIterator __first, _InputIterator __last)
       {
-	forward_list __tmp(__first, __last, this->_M_get_Node_allocator());
+	forward_list __tmp(__first, __last, get_allocator());
 	if (!__tmp.empty())
 	  return _M_splice_after(__pos, std::move(__tmp));
 	else
@@ -278,7 +278,7 @@ 
     {
       if (__il.size())
 	{
-	  forward_list __tmp(__il, this->_M_get_Node_allocator());
+	  forward_list __tmp(__il, get_allocator());
 	  return _M_splice_after(__pos, std::move(__tmp));
 	}
       else
Index: include/bits/stl_tree.h
===================================================================
--- include/bits/stl_tree.h	(revision 178206)
+++ include/bits/stl_tree.h	(working copy)
@@ -624,7 +624,7 @@ 
 
       _Rb_tree(const _Compare& __comp,
 	       const allocator_type& __a = allocator_type())
-      : _M_impl(__comp, __a) { }
+      : _M_impl(__comp, _Node_allocator(__a)) { }
 
       _Rb_tree(const _Rb_tree& __x)
       : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator())
Index: testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <unordered_map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+				  __gnu_test::ExplicitConsAlloc<int>>;
+template class std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+				  __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::multimap<int, int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<int> >;
+template class std::multimap<int, int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<char> >;
Index: testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc
===================================================================
--- testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
+++ testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::multimap<int, int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<int>>;
+template class std::multimap<int, int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/set/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/set/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/set/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::set<int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<int> >;
+template class std::set<int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<char> >;
Index: testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc
===================================================================
--- testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
+++ testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::set<int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<int>>;
+template class std::set<int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,33 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <unordered_map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::unordered_multimap<int, int, std::hash<int>,
+				       std::equal_to<int>,
+				       __gnu_test::ExplicitConsAlloc<int>>;
+template class std::unordered_multimap<int, int, std::hash<int>,
+				       std::equal_to<int>,
+				       __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc	(revision 178206)
+++ testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc	(working copy)
@@ -1,8 +1,8 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1210 }
+// { dg-error "no matching" "" { target *-*-* } 1211 }
 
-// Copyright (C) 2009, 2010 Free Software Foundation
+// Copyright (C) 2009, 2010, 2011 Free Software Foundation
 //
 // 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
Index: testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc	(revision 178206)
+++ testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1210 }
+// { dg-error "no matching" "" { target *-*-* } 1211 }
 
 // Copyright (C) 2009, 2010, 2011 Free Software Foundation
 //
Index: testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc	(revision 178206)
+++ testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1210 }
+// { dg-error "no matching" "" { target *-*-* } 1211 }
 
 // Copyright (C) 2009, 2010, 2011 Free Software Foundation
 //
Index: testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc	(revision 178206)
+++ testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1210 }
+// { dg-error "no matching" "" { target *-*-* } 1211 }
 
 // Copyright (C) 2009, 2010, 2011 Free Software Foundation
 //
Index: testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <forward_list>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::forward_list<int, __gnu_test::ExplicitConsAlloc<int>>;
+template class std::forward_list<int, __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <unordered_set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::unordered_set<int, std::hash<int>, std::equal_to<int>,
+				  __gnu_test::ExplicitConsAlloc<int>>;
+template class std::unordered_set<int, std::hash<int>, std::equal_to<int>,
+				  __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::multiset<int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<int> >;
+template class std::multiset<int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<char> >;
Index: testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc
===================================================================
--- testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
+++ testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::multiset<int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<int>>;
+template class std::multiset<int, std::less<int>,
+			     __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/list/requirements/dr438/assign_neg.cc
===================================================================
--- testsuite/23_containers/list/requirements/dr438/assign_neg.cc	(revision 178206)
+++ testsuite/23_containers/list/requirements/dr438/assign_neg.cc	(working copy)
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1498 }
+// { dg-error "no matching" "" { target *-*-* } 1499 }
 
 #include <list>
 
Index: testsuite/23_containers/list/requirements/dr438/insert_neg.cc
===================================================================
--- testsuite/23_containers/list/requirements/dr438/insert_neg.cc	(revision 178206)
+++ testsuite/23_containers/list/requirements/dr438/insert_neg.cc	(working copy)
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1454 }
+// { dg-error "no matching" "" { target *-*-* } 1455 }
 
 #include <list>
 
Index: testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
===================================================================
--- testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc	(revision 178206)
+++ testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc	(working copy)
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1454 }
+// { dg-error "no matching" "" { target *-*-* } 1455 }
 
 #include <list>
 
Index: testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
===================================================================
--- testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc	(revision 178206)
+++ testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc	(working copy)
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1454 }
+// { dg-error "no matching" "" { target *-*-* } 1455 }
 
 #include <list>
 #include <utility>
Index: testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc
===================================================================
--- testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
+++ testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <list>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::list<int, __gnu_test::ExplicitConsAlloc<int>>;
+template class std::list<int, __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/list/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/list/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/list/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,27 @@ 
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <list>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::list<int, __gnu_test::ExplicitConsAlloc<int> >;
+template class std::list<int, __gnu_test::ExplicitConsAlloc<char> >;
Index: testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <unordered_set>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::unordered_multiset<int, std::hash<int>, std::equal_to<int>,
+				       __gnu_test::ExplicitConsAlloc<int>>;
+template class std::unordered_multiset<int, std::hash<int>, std::equal_to<int>,
+				       __gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/23_containers/map/requirements/explicit_instantiation/5.cc
===================================================================
--- testsuite/23_containers/map/requirements/explicit_instantiation/5.cc	(revision 0)
+++ testsuite/23_containers/map/requirements/explicit_instantiation/5.cc	(revision 0)
@@ -0,0 +1,29 @@ 
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::map<int, int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<int> >;
+template class std::map<int, int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<char> >;
Index: testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc
===================================================================
--- testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
+++ testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc	(revision 0)
@@ -0,0 +1,31 @@ 
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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/>.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+#include <testsuite_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/50118
+template class std::map<int, int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<int>>;
+template class std::map<int, int, std::less<int>,
+			__gnu_test::ExplicitConsAlloc<char>>;
Index: testsuite/util/testsuite_allocator.h
===================================================================
--- testsuite/util/testsuite_allocator.h	(revision 178206)
+++ testsuite/util/testsuite_allocator.h	(working copy)
@@ -434,6 +434,20 @@ 
 
 #endif
 
+  template<typename Tp>
+    struct ExplicitConsAlloc : std::allocator<Tp>
+    {
+      ExplicitConsAlloc() { }
+
+      template<typename Up>
+        explicit
+        ExplicitConsAlloc(const ExplicitConsAlloc<Up>&) { }
+
+      template<typename Up>
+        struct rebind
+        { typedef ExplicitConsAlloc<Up> other; };
+    };
+
 } // namespace __gnu_test
 
 #endif // _GLIBCXX_TESTSUITE_ALLOCATOR_H