]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix vector::_Temporary_value::_M_ptr
authorJonathan Wakely <jwakely@redhat.com>
Mon, 3 Sep 2018 14:25:29 +0000 (15:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 3 Sep 2018 14:25:29 +0000 (15:25 +0100)
The pointer argument to allocator_traits::construct and
allocator_traits::destroy should be a raw pointer, not the allocator's
pointer type. _Temporary_value::_M_ptr was returning the wrong type.

* include/bits/stl_vector.h (vector::_Temporary_value::_M_ptr):
Return raw pointer not allocator's pointer type.
(vector::_Temporary_value::_M_val): Use _M_ptr.

From-SVN: r264061

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_vector.h

index 6a576baeed5135ce9f8184681049e4b9944e9ef3..9fddb1e9ee0fa04d0d349603a7508a0a6eca377c 100644 (file)
@@ -1,5 +1,9 @@
 2018-09-03  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/bits/stl_vector.h (vector::_Temporary_value::_M_ptr):
+       Return raw pointer not allocator's pointer type.
+       (vector::_Temporary_value::_M_val): Use _M_ptr.
+
        PR libstdc++/87194
        * include/bits/stl_map.h
        (map::map(initializer_list<value_type>, const Compare&, const Alloc&))
index 6bb75b7f8fd556cce0fa47e948d49fcf757f411e..478564731076d8cb6e52e389114d2ecc452cfed3 100644 (file)
@@ -1667,11 +1667,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
 
        value_type&
-       _M_val() { return *reinterpret_cast<_Tp*>(&__buf); }
+       _M_val() { return *_M_ptr(); }
 
       private:
-       pointer
-       _M_ptr() { return pointer_traits<pointer>::pointer_to(_M_val()); }
+       _Tp*
+       _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); }
 
        vector* _M_this;
        typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __buf;