public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix vector::_Temporary_value::_M_ptr
@ 2018-09-03 14:25 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2018-09-03 14:25 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 404 bytes --]

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.

Tested x86_64-lixnu, committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1277 bytes --]

commit 5368f71250324a046e5f026fef33a3e12176c243
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Sep 3 15:01:32 2018 +0100

    Fix vector::_Temporary_value::_M_ptr
    
    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.

diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index 6bb75b7f8fd..47856473107 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-09-03 14:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03 14:25 [PATCH] Fix vector::_Temporary_value::_M_ptr Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).