]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorPaolo Carlini <paolo@gcc.gnu.org>
Thu, 20 May 2010 22:35:49 +0000 (22:35 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 20 May 2010 22:35:49 +0000 (22:35 +0000)
2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/41792
* include/tr1_impl/array: Use std::__addressof.
* include/std/functional (reference_wrapper): Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/ext/pool_allocator.h: Likewise.
* include/ext/bitmap_allocator.h: Likewise.
* include/ext/new_allocator.h: Likewise.
* include/ext/malloc_allocator.h: Likewise.
* include/ext/array_allocator.h: Likewise.
* include/ext/mt_allocator.h: Likewise.
* include/ext/extptr_allocator.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/forward_list.h: Likewise.
* include/bits/stl_uninitialized.h: Likewise.
* include/bits/list.tcc: Likewise.
* include/bits/stl_construct.h: Likewise.
* include/bits/stl_tree.h: Likewise.
* testsuite/20_util/reference_wrapper/41792.cc: New.
* testsuite/23_containers/unordered_map/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/multimap/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/set/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_multimap/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_set/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/vector/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/deque/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/multiset/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/list/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_multiset/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/map/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/array/requirements/
explicit_instantiation/3.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/
dr438/assign_neg.cc: Adjust dg-error line numbers.
* 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.

2010-05-20  Peter Dimov  <pdimov@pdimov.com>
    Paolo Carlini  <paolo.carlini@oracle.com>

* include/bits/move.h (__addressof, addressof): Add.
* testsuite/util/testsuite_api.h (struct OverloadedAddress): Add.
* testsuite/20_util/addressof/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/addressof/1.cc: Likewise.

From-SVN: r159643

44 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/bits/list.tcc
libstdc++-v3/include/bits/move.h
libstdc++-v3/include/bits/stl_construct.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/include/bits/stl_uninitialized.h
libstdc++-v3/include/ext/array_allocator.h
libstdc++-v3/include/ext/bitmap_allocator.h
libstdc++-v3/include/ext/extptr_allocator.h
libstdc++-v3/include/ext/malloc_allocator.h
libstdc++-v3/include/ext/mt_allocator.h
libstdc++-v3/include/ext/new_allocator.h
libstdc++-v3/include/ext/pool_allocator.h
libstdc++-v3/include/ext/throw_allocator.h
libstdc++-v3/include/std/functional
libstdc++-v3/include/tr1_impl/array
libstdc++-v3/testsuite/20_util/addressof/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/util/testsuite_api.h

index be72417645ddd057b05152e66d85389ca8e1138b..fb99088a2b44665300fa7bd7496b689d284fcfde 100644 (file)
@@ -1,3 +1,76 @@
+2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/41792
+       * include/tr1_impl/array: Use std::__addressof.
+       * include/std/functional (reference_wrapper): Likewise.
+       * include/ext/throw_allocator.h: Likewise.
+       * include/ext/pool_allocator.h: Likewise.
+       * include/ext/bitmap_allocator.h: Likewise.
+       * include/ext/new_allocator.h: Likewise.
+       * include/ext/malloc_allocator.h: Likewise.
+       * include/ext/array_allocator.h: Likewise.
+       * include/ext/mt_allocator.h: Likewise.
+       * include/ext/extptr_allocator.h: Likewise.
+       * include/bits/stl_list.h: Likewise.
+       * include/bits/hashtable_policy.h: Likewise.
+       * include/bits/forward_list.h: Likewise.
+       * include/bits/stl_uninitialized.h: Likewise.
+       * include/bits/list.tcc: Likewise.
+       * include/bits/stl_construct.h: Likewise.
+       * include/bits/stl_tree.h: Likewise.
+       * testsuite/20_util/reference_wrapper/41792.cc: New.
+       * testsuite/23_containers/unordered_map/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/multimap/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/set/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/unordered_multimap/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/forward_list/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/unordered_set/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/multiset/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/list/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/unordered_multiset/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/map/requirements/
+       explicit_instantiation/4.cc: Likewise.
+       * testsuite/23_containers/array/requirements/
+       explicit_instantiation/3.cc: Likewise.
+       * testsuite/23_containers/forward_list/requirements/
+       dr438/assign_neg.cc: Adjust dg-error line numbers.
+       * 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.
+
+2010-05-20  Peter Dimov  <pdimov@pdimov.com>
+           Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/bits/move.h (__addressof, addressof): Add.
+       * testsuite/util/testsuite_api.h (struct OverloadedAddress): Add.
+       * testsuite/20_util/addressof/requirements/
+       explicit_instantiation.cc: New.
+       * testsuite/20_util/addressof/1.cc: Likewise.
+
 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/bits/stl_pair.h (pair<>::pair(const pair&)): Defaulted
index 57b7836a3243e916f1ffa63a35ba75c62aafde3f..c0c135cd1b36bc9b0f0a22882e5ed6f208dbba06 100644 (file)
@@ -139,7 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return std::__addressof(static_cast<_Node*>
+                               (this->_M_node)->_M_value); }
 
       _Self&
       operator++()
@@ -210,7 +211,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return std::__addressof(static_cast<_Node*>
+                               (this->_M_node)->_M_value); }
 
       _Self&
       operator++()
index 6e6a8fb0177e727d02e29f62f7dd3ad2d6276ec1..694d0ffdeb42796302d37d5a17721dc9d3a58763 100644 (file)
@@ -145,7 +145,7 @@ namespace __detail
   
       pointer
       operator->() const
-      { return &this->_M_cur->_M_v; }
+      { return std::__addressof(this->_M_cur->_M_v); }
 
       _Node_iterator&
       operator++()
@@ -190,7 +190,7 @@ namespace __detail
   
       pointer
       operator->() const
-      { return &this->_M_cur->_M_v; }
+      { return std::__addressof(this->_M_cur->_M_v); }
 
       _Node_const_iterator&
       operator++()
@@ -288,7 +288,7 @@ namespace __detail
   
       pointer
       operator->() const
-      { return &this->_M_cur_node->_M_v; }
+      { return std::__addressof(this->_M_cur_node->_M_v); }
 
       _Hashtable_iterator&
       operator++()
@@ -338,7 +338,7 @@ namespace __detail
   
       pointer
       operator->() const
-      { return &this->_M_cur_node->_M_v; }
+      { return std::__addressof(this->_M_cur_node->_M_v); }
 
       _Hashtable_const_iterator&
       operator++()
index 535923981a5f0cf24c71413f5d47640d45b81d6b..f1c4a10dd664dd8120c82ede2d88e20ffba703c8 100644 (file)
@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
          _M_get_Node_allocator().destroy(__tmp);
 #else
-         _M_get_Tp_allocator().destroy(&__tmp->_M_data);
+         _M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
 #endif
          _M_put_node(__tmp);
        }
@@ -198,7 +198,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
              // _GLIBCXX_RESOLVE_LIB_DEFECTS
              // 526. Is it undefined if a function in the standard changes
              // in parameters?
-             if (&*__first != &__value)
+             if (std::__addressof(*__first) != std::__addressof(__value))
                _M_erase(__first);
              else
                __extra = __first;
index 91754814d8bc1e44c470ccd9a71238b3067b00c2..a137f982bedb4eb7a046734cd5aa19654749867a 100644 (file)
@@ -1,6 +1,6 @@
 // Move, forward and identity for C++0x + swap -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 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
 #include <cstddef>
 #include <bits/concept_check.h>
 
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+  // Used, in C++03 mode too, by allocators, etc.
+  template<typename _Tp>
+    inline _Tp*
+    __addressof(_Tp& __r)
+    {
+      return reinterpret_cast<_Tp*>
+       (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
+    }
+
+_GLIBCXX_END_NAMESPACE
+
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <type_traits> // Brings in std::declval too.
 
@@ -83,6 +96,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
   /// declval, defined in <type_traits>.
 
+  /**
+   *  @brief Returns the actual address of the object or function
+   *         referenced by r, even in the presence of an overloaded
+   *         operator&.
+   *  @param  __r  Reference to an object or function.
+   *  @return   The actual address.
+  */
+  template<typename _Tp>
+    inline _Tp*
+    addressof(_Tp& __r)
+    { return std::__addressof(__r); }
+
 _GLIBCXX_END_NAMESPACE
 
 #define _GLIBCXX_MOVE(_Tp) std::move(_Tp)
index 3c30b9a45043efffd9776065367b973e543361a8..06a2902ca69fab904418e02bee397a6a6a9dd9e6 100644 (file)
@@ -1,6 +1,7 @@
 // nonstandard construct and destroy functions -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -96,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
         __destroy(_ForwardIterator __first, _ForwardIterator __last)
        {
          for (; __first != __last; ++__first)
-           std::_Destroy(&*__first);
+           std::_Destroy(std::__addressof(*__first));
        }
     };
 
@@ -137,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
             _Allocator& __alloc)
     {
       for (; __first != __last; ++__first)
-       __alloc.destroy(&*__first);
+       __alloc.destroy(std::__addressof(*__first));
     }
 
   template<typename _ForwardIterator, typename _Tp>
index 5fcbc4f347037b186be1cf88149b8f2c294da381..56357ed07da9f94703875dd2261974c417ed5834 100644 (file)
@@ -128,14 +128,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       _List_iterator(_List_node_base* __x)
       : _M_node(__x) { }
 
-      // Must downcast from List_node_base to _List_node to get to _M_data.
+      // Must downcast from _List_node_base to _List_node to get to _M_data.
       reference
       operator*() const
       { return static_cast<_Node*>(_M_node)->_M_data; }
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(_M_node)->_M_data; }
+      { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
 
       _Self&
       operator++()
@@ -215,7 +215,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(_M_node)->_M_data; }
+      { return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
 
       _Self&
       operator++()
@@ -461,7 +461,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        _Node* __p = this->_M_get_node();
        __try
          {
-           _M_get_Tp_allocator().construct(&__p->_M_data, __x);
+           _M_get_Tp_allocator().construct
+             (std::__addressof(__p->_M_data), __x);
          }
        __catch(...)
          {
@@ -1453,7 +1454,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
         _M_get_Node_allocator().destroy(__n);
 #else
-       _M_get_Tp_allocator().destroy(&__n->_M_data);
+       _M_get_Tp_allocator().destroy(std::__addressof(__n->_M_data));
 #endif
         _M_put_node(__n);
       }
index d37dc57246e4c8a0b1644df497748bdb10b054f5..58c63cf437621ab1077185fc176725b87c18ee62 100644 (file)
@@ -1,6 +1,7 @@
 // RB tree implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -176,7 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
+      { return std::__addressof(static_cast<_Link_type>
+                               (_M_node)->_M_value_field); }
 
       _Self&
       operator++()
@@ -251,7 +253,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
+      { return std::__addressof(static_cast<_Link_type>
+                               (_M_node)->_M_value_field); }
 
       _Self&
       operator++()
@@ -368,7 +371,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       {
        _Link_type __tmp = _M_get_node();
        __try
-         { get_allocator().construct(&__tmp->_M_value_field, __x); }
+         { get_allocator().construct
+             (std::__addressof(__tmp->_M_value_field), __x); }
        __catch(...)
          {
            _M_put_node(__tmp);
@@ -380,7 +384,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       void
       _M_destroy_node(_Link_type __p)
       {
-       get_allocator().destroy(&__p->_M_value_field);
+       get_allocator().destroy(std::__addressof(__p->_M_value_field));
        _M_put_node(__p);
       }
 #else
index 4b6399d9961b325034ca3973e72c3f7f8ecb79e0..b78f92025c353f09c0c82a7a9e1ca66977cdc730 100644 (file)
@@ -1,6 +1,7 @@
 // Raw memory manipulators -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -71,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          __try
            {
              for (; __first != __last; ++__first, ++__cur)
-               std::_Construct(&*__cur, *__first);
+               std::_Construct(std::__addressof(*__cur), *__first);
              return __cur;
            }
          __catch(...)
@@ -129,7 +130,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          __try
            {
              for (; __cur != __last; ++__cur)
-               std::_Construct(&*__cur, __x);
+               std::_Construct(std::__addressof(*__cur), __x);
            }
          __catch(...)
            {
@@ -185,11 +186,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          _ForwardIterator __cur = __first;
          __try
            {
-             std::_Construct(&*__first, _GLIBCXX_MOVE(__value));
+             std::_Construct(std::__addressof(*__first),
+                             _GLIBCXX_MOVE(__value));
              _ForwardIterator __prev = __cur;
              ++__cur;
              for(; __cur != __last; ++__cur, ++__prev)
-               std::_Construct(&*__cur, _GLIBCXX_MOVE(*__prev));
+               std::_Construct(std::__addressof(*__cur),
+                               _GLIBCXX_MOVE(*__prev));
              __value = _GLIBCXX_MOVE(*__prev);
            }
          __catch(...)
@@ -245,7 +248,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          __try
            {
              for (; __n > 0; --__n, ++__cur)
-               std::_Construct(&*__cur, __x);
+               std::_Construct(std::__addressof(*__cur), __x);
            }
          __catch(...)
            {
@@ -301,7 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       __try
        {
          for (; __first != __last; ++__first, ++__cur)
-           __alloc.construct(&*__cur, *__first);
+           __alloc.construct(std::__addressof(*__cur), *__first);
          return __cur;
        }
       __catch(...)
@@ -337,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       __try
        {
          for (; __cur != __last; ++__cur)
-           __alloc.construct(&*__cur, __x);
+           __alloc.construct(std::__addressof(*__cur), __x);
        }
       __catch(...)
        {
@@ -362,7 +365,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       __try
        {
          for (; __n > 0; --__n, ++__cur)
-           __alloc.construct(&*__cur, __x);
+           __alloc.construct(std::__addressof(*__cur), __x);
        }
       __catch(...)
        {
@@ -498,7 +501,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       __try
        {
          for (; __n > 0; --__n, ++__first, ++__cur)
-           ::new(static_cast<void*>(&*__cur)) typename
+           ::new(static_cast<void*>(std::__addressof(*__cur))) typename
                iterator_traits<_ForwardIterator>::value_type(*__first);
          return __cur;
        }
index f36f273d1fefe529211bbfe71b6b2741d7c8f22d..36f15fe936cb95fa80af761ea9884ec6fc9031cf 100644 (file)
@@ -1,6 +1,6 @@
 // array allocator -*- C++ -*-
 
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -55,10 +55,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       typedef _Tp              value_type;
 
       pointer
-      address(reference __x) const { return &__x; }
+      address(reference __x) const { return std::__addressof(__x); }
 
       const_pointer
-      address(const_reference __x) const { return &__x; }
+      address(const_reference __x) const { return std::__addressof(__x); }
 
       void
       deallocate(pointer, size_type)
index d91d9aa5cc699c781729fb2c78a47f1027a7ce87..05285f548cc5b09d621e8fbd20d5f85968f7317d 100644 (file)
@@ -1,6 +1,6 @@
 // Bitmap Allocator. -*- C++ -*-
 
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -1039,11 +1039,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
       pointer 
       address(reference __r) const
-      { return &__r; }
+      { return std::__addressof(__r); }
 
       const_pointer 
       address(const_reference __r) const
-      { return &__r; }
+      { return std::__addressof(__r); }
 
       size_type 
       max_size() const throw()
index fab6b1d85edd7a4379ff9312d12ca38adc8e945b..d9e8cda440dd4572445e0444e0982f73b6ab8768 100644 (file)
@@ -1,6 +1,6 @@
 // <extptr_allocator.h> -*- C++ -*-
 
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010 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
@@ -82,10 +82,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       { }
 
       pointer address(reference __x) const
-      { return &__x; }
+      { return std::__addressof(__x); }
 
       const_pointer address(const_reference __x) const
-      { return &__x; }
+      { return std::__addressof(__x); }
 
       pointer allocate(size_type __n, void* __hint = 0)
       { return _M_real_alloc.allocate(__n,__hint); }
index b432c63a61eaf9189316908ac312874f2ac1b723..ed3c3b2b0ac981075fe4132d8301b1028ee19167 100644 (file)
@@ -1,6 +1,6 @@
 // Allocator that wraps "C" malloc -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -74,10 +74,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       ~malloc_allocator() throw() { }
 
       pointer
-      address(reference __x) const { return &__x; }
+      address(reference __x) const { return std::__addressof(__x); }
 
       const_pointer
-      address(const_reference __x) const { return &__x; }
+      address(const_reference __x) const { return std::__addressof(__x); }
 
       // NB: __n is permitted to be 0.  The C++ standard says nothing
       // about what the return value is when __n == 0.
index 0e675133296d6def8e0dcf6df312c9a8b154d533..8fdb2f6393b5f09cfa756a34205196f6b1ee322c 100644 (file)
@@ -576,11 +576,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
       pointer
       address(reference __x) const
-      { return &__x; }
+      { return std::__addressof(__x); }
 
       const_pointer
       address(const_reference __x) const
-      { return &__x; }
+      { return std::__addressof(__x); }
 
       size_type
       max_size() const throw() 
index 51666c3c7fdef062ea1744c9490a5c9eb9a0c942..beaddddf9eed6a3e78faf97271fef8f5f801fc40 100644 (file)
@@ -1,6 +1,6 @@
 // Allocator that wraps operator new -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -73,10 +73,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       ~new_allocator() throw() { }
 
       pointer
-      address(reference __x) const { return &__x; }
+      address(reference __x) const { return std::__addressof(__x); }
 
       const_pointer
-      address(const_reference __x) const { return &__x; }
+      address(const_reference __x) const { return std::__addressof(__x); }
 
       // NB: __n is permitted to be 0.  The C++ standard says nothing
       // about what the return value is when __n == 0.
index b1e61841c0a74116ce3a3574facfd310fcabf30d..66cda84b42d3491ddfbcf7e0ae6459ece85c712e 100644 (file)
@@ -1,6 +1,6 @@
 // Allocators -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -147,10 +147,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       ~__pool_alloc() throw() { }
 
       pointer
-      address(reference __x) const { return &__x; }
+      address(reference __x) const { return std::__addressof(__x); }
 
       const_pointer
-      address(const_reference __x) const { return &__x; }
+      address(const_reference __x) const { return std::__addressof(__x); }
 
       size_type
       max_size() const throw() 
index 48089bd7dd04d17b069841c92d008c277b5546fd..70b197a705d1d7934e45fff665266f9b6fbc90a5 100644 (file)
@@ -619,6 +619,12 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       max_size() const throw()
       { return _M_allocator.max_size(); }
 
+      pointer
+      address(reference __x) const { return std::__addressof(__x); }
+
+      const_pointer
+      address(const_reference __x) const { return std::__addressof(__x); }
+
       pointer
       allocate(size_type __n, std::allocator<void>::const_pointer hint = 0)
       {
index 7de7edfff9ab77f00fd6e800470813e2d35dffe1..7f6d8b6c4f663d660ae4af6024a644bf414380c1 100644 (file)
@@ -390,7 +390,8 @@ namespace std
     public:
       typedef _Tp type;
 
-      reference_wrapper(_Tp& __indata): _M_data(&__indata)
+      reference_wrapper(_Tp& __indata)
+      : _M_data(std::__addressof(__indata))
       { }
 
       reference_wrapper(_Tp&&) = delete;
index edc4aec90b4ed266594f97d31f61b69f30abd33f..db0364e535723bda0f4ff3d63680ec5f9802fbc7 100644 (file)
@@ -83,19 +83,19 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
       // Iterators.
       iterator
       begin()
-      { return iterator(&_M_instance[0]); }
+      { return iterator(std::__addressof(_M_instance[0])); }
 
       const_iterator
       begin() const 
-      { return const_iterator(&_M_instance[0]); }
+      { return const_iterator(std::__addressof(_M_instance[0])); }
 
       iterator
       end()
-      { return iterator(&_M_instance[_Nm]); }
+      { return iterator(std::__addressof(_M_instance[_Nm])); }
 
       const_iterator
       end() const
-      { return const_iterator(&_M_instance[_Nm]); }
+      { return const_iterator(std::__addressof(_M_instance[_Nm])); }
 
       reverse_iterator 
       rbegin()
@@ -116,11 +116,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
       const_iterator
       cbegin() const 
-      { return const_iterator(&_M_instance[0]); }
+      { return const_iterator(std::__addressof(_M_instance[0])); }
 
       const_iterator
       cend() const
-      { return const_iterator(&_M_instance[_Nm]); }
+      { return const_iterator(std::__addressof(_M_instance[_Nm])); }
 
       const_reverse_iterator 
       crbegin() const
@@ -182,13 +182,13 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
       back() const
       { return _Nm ? *(end() - 1) : *end(); }
 
-      _Tp* 
+      _Tp*
       data()
-      { return &_M_instance[0]; }
+      { return std::__addressof(_M_instance[0]); }
 
-      const _Tp* 
+      const _Tp*
       data() const
-      { return &_M_instance[0]; }
+      { return std::__addressof(_M_instance[0]); }
     };
 
   // Array comparisons.
diff --git a/libstdc++-v3/testsuite/20_util/addressof/1.cc b/libstdc++-v3/testsuite/20_util/addressof/1.cc
new file mode 100644 (file)
index 0000000..43009f3
--- /dev/null
@@ -0,0 +1,51 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 <memory>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void f1(int) { }
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+  using namespace __gnu_test;
+  
+  OverloadedAddress* ao1 = new OverloadedAddress();
+  OverloadedAddress& o1 = *ao1;
+
+  VERIFY( std::addressof(o1) == ao1 );
+
+  const OverloadedAddress* ao2 = new OverloadedAddress();
+  const OverloadedAddress& o2 = *ao2;
+
+  VERIFY( std::addressof(o2) == ao2 );
+
+  VERIFY( std::addressof(f1) == &f1 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc
new file mode 100644 (file)
index 0000000..559cd20
--- /dev/null
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+// NB: This file is for testing utility with NO OTHER INCLUDES.
+
+#include <memory>
+
+namespace std
+{
+  typedef short test_type;
+  template short* addressof(short&);
+}
diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc
new file mode 100644 (file)
index 0000000..b167d71
--- /dev/null
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 <functional>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+// libstdc++/41792
+void test01()
+{
+  using namespace __gnu_test;
+
+  OverloadedAddress* ao1 = new OverloadedAddress();
+  std::reference_wrapper<OverloadedAddress> rw1(*ao1);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc
new file mode 100644 (file)
index 0000000..9bd5bc9
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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 <array>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+// libstdc++/41792
+template class std::array<__gnu_test::OverloadedAddress, 3>;
diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..4685ae1
--- /dev/null
@@ -0,0 +1,30 @@
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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 <deque>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::deque<__gnu_test::OverloadedAddress>;
index 8d72db59c8b821774b503ff25034bab0b2450294..1625e3bc76bef850529f310a5527a73581938429 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1194 }
+// { dg-error "no matching" "" { target *-*-* } 1196 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 5f5ac2c7713acbcacbf0baadca75a02046d80197..5acfcd1f47f6908cacbc7721d6dc364d94d4db48 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1194 }
+// { dg-error "no matching" "" { target *-*-* } 1196 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 340a6be65e3d620fb2644badec436e45f7d5b1f9..dcf69089b004a4b60ca342955cf4af7069d4b454 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1194 }
+// { dg-error "no matching" "" { target *-*-* } 1196 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 1173dc1b697aaf046c1c59cc9e87a11be628e5d9..22574fd081a16d5c413e4623aeb6d4a49869d027 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1194 }
+// { dg-error "no matching" "" { target *-*-* } 1196 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..11f1524
--- /dev/null
@@ -0,0 +1,32 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::forward_list<__gnu_test::OverloadedAddress>;
index d41e1498069062a4febc3aaf8e6295beb4203c69..eb35a24c89d7eab21549b08f5ef50a982bf4ef8c 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1410 }
+// { dg-error "no matching" "" { target *-*-* } 1411 }
 // { dg-excess-errors "" }
 
 #include <list>
index 01d9135c8608a606da39ef6685b45843f4fab704..937404b26a8c0deb63b89a10198f4288e1d598f8 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1379 }
+// { dg-error "no matching" "" { target *-*-* } 1380 }
 // { dg-excess-errors "" }
 
 #include <list>
index c13f6565df4b4af8c991f3c26989af6286f5adf3..74fc1b7a1630299ec1a5ed9a340452cac9b75275 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1379 }
+// { dg-error "no matching" "" { target *-*-* } 1380 }
 // { dg-excess-errors "" }
 
 #include <list>
index 262a7a15f9430c018a8e4fcd454db2a3c60a5f45..3aebda5ddb2af7464da6904378ccacc3f7a086ab 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1379 }
+// { dg-error "no matching" "" { target *-*-* } 1380 }
 // { dg-excess-errors "" }
 
 #include <list>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..7ad82a3
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::list<__gnu_test::OverloadedAddress>;
diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..2a3700a
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::map<__gnu_test::OverloadedAddress,
+                       __gnu_test::OverloadedAddress>;
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..82bd4cd
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::multimap<__gnu_test::OverloadedAddress,
+                            __gnu_test::OverloadedAddress>;
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..d55064c
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::multiset<__gnu_test::OverloadedAddress>;
diff --git a/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..2bbe976
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// 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_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::set<__gnu_test::OverloadedAddress>;
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..37b57b3
--- /dev/null
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_api.h>
+
+typedef __gnu_test::OverloadedAddress      inst_type;
+typedef __gnu_test::OverloadedAddress_hash hash_type;
+
+// libstdc++/41792
+template class std::unordered_map<inst_type, inst_type, hash_type>;
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..d92fdc5
--- /dev/null
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_api.h>
+
+typedef __gnu_test::OverloadedAddress      inst_type;
+typedef __gnu_test::OverloadedAddress_hash hash_type;
+
+// libstdc++/41792
+template class std::unordered_multimap<inst_type, inst_type, hash_type>;
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..6184026
--- /dev/null
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_api.h>
+
+typedef __gnu_test::OverloadedAddress      inst_type;
+typedef __gnu_test::OverloadedAddress_hash hash_type;
+
+// libstdc++/41792
+template class std::unordered_multiset<inst_type, hash_type>;
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..3f619b7
--- /dev/null
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_api.h>
+
+typedef __gnu_test::OverloadedAddress      inst_type;
+typedef __gnu_test::OverloadedAddress_hash hash_type;
+
+// libstdc++/41792
+template class std::unordered_set<inst_type, hash_type>;
diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc
new file mode 100644 (file)
index 0000000..9305e3c
--- /dev/null
@@ -0,0 +1,29 @@
+// 2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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 <vector>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+// { dg-do compile }
+
+// libstdc++/41792
+template class std::vector<__gnu_test::OverloadedAddress>;
index 4dc4a6fb7bba13543f924c1bd785393f6b821a28..fcb762eff66427a1308796f20bbb44b4a7eeb9a7 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 // Exception testing utils for the C++ library testsuite. 
 //
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 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
@@ -150,6 +150,30 @@ namespace __gnu_test
       operator()() const
       { return result_type(2); }
     };
+
+  // For std::addressof, etc.
+  struct OverloadedAddressAux { };
+  
+  struct OverloadedAddress
+  {
+    OverloadedAddressAux
+    operator&() const { return OverloadedAddressAux(); }
+  };
+
+  inline bool
+  operator<(const OverloadedAddress&, const OverloadedAddress&)
+  { return false; }
+
+  inline bool
+  operator==(const OverloadedAddress&, const OverloadedAddress&)
+  { return false; }
+
+  struct OverloadedAddress_hash
+  {
+    size_t
+    operator()(const OverloadedAddress&) const
+    { return 1; }
+  };
 }
 
 #endif