This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Make std::list safe against overloaded operator&


On 16/06/15 22:05 +0100, Jonathan Wakely wrote:
This fixes some unsafe uses of operator& in std::list, and also in
Debug Mode found running the new test with -D_GLIBCXX_DEBUG.

And another related patch, found after rebasing some std::list changes
I've been working on.

Tested powerpc64le-linux, committed to trunk.

commit 7c2d6125ffabb27c89ad3c2345ab90bc8159e550
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 16 22:29:37 2015 +0100

    	* include/bits/allocated_ptr.h (__allocated_ptr): Use __addressof.

diff --git a/libstdc++-v3/include/bits/allocated_ptr.h b/libstdc++-v3/include/bits/allocated_ptr.h
index 63088c2..d7f00d7 100644
--- a/libstdc++-v3/include/bits/allocated_ptr.h
+++ b/libstdc++-v3/include/bits/allocated_ptr.h
@@ -50,14 +50,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       /// Take ownership of __ptr
       __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
-      : _M_alloc(&__a), _M_ptr(__ptr)
+      : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
       { }
 
       /// Convert __ptr to allocator's pointer type and take ownership of it
       template<typename _Ptr,
 	       typename _Req = _Require<is_same<_Ptr, value_type*>>>
       __allocated_ptr(_Alloc& __a, _Ptr __ptr)
-      : _M_alloc(&__a), _M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
+      : _M_alloc(std::__addressof(__a)),
+	_M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
       { }
 
       /// Transfer ownership of the owned pointer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]