diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-01-29 00:47:25 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-01-29 00:47:25 +0000 |
commit | 1f48525ded40b968792c4dfd9a7614c3e88129a4 (patch) | |
tree | fc2d3d9bb79c9d94adc789855952b43be97fb435 /libstdc++-v3 | |
parent | a097ba8abb6ca31638a5ad3f1f49a21c1b772839 (diff) | |
download | gcc-1f48525ded40b968792c4dfd9a7614c3e88129a4.zip gcc-1f48525ded40b968792c4dfd9a7614c3e88129a4.tar.gz gcc-1f48525ded40b968792c4dfd9a7614c3e88129a4.tar.bz2 |
Ensure pool resources always use normal mode vector
The __pool_resource::_M_unpooled member was declared with type
std::vector, which means that the type depends on whether debug mode is
active or not. Because the non-inline definitions in
src/c++17/memory_resource.cc are never compiled with debug mode, the
type declared in the header doesn't match the type in the library
definitions, leading to undefined behaviour.
The solution is to ensure the header always uses the non-debug vector,
even when debug mode is active. To make this easier a new alias template
is defined: _GLIBCXX_STD_C::pmr::vector.
* include/std/memory_resource (__pool_resource::_M_unpooled): Use
normal mode vector, even for debug mode.
* include/std/vector [_GLIBCXX_DEBUG] (_GLIBCXX_STD_C::pmr::vector):
Define alias template for normal mode vector.
From-SVN: r268354
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/std/memory_resource | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/std/vector | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 89b94a8..3003852 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2019-01-29 Jonathan Wakely <jwakely@redhat.com> + + * include/std/memory_resource (__pool_resource::_M_unpooled): Use + normal mode vector, even for debug mode. + * include/std/vector [_GLIBCXX_DEBUG] (_GLIBCXX_STD_C::pmr::vector): + Define alias template for normal mode vector. + 2019-01-28 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/68737 diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index 5573494..93b2ebd 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -354,7 +354,7 @@ namespace pmr struct _BigBlock; // Collection of blocks too big for any pool, sorted by address. // This also stores the only copy of the upstream memory resource pointer. - pmr::vector<_BigBlock> _M_unpooled; + _GLIBCXX_STD_C::pmr::vector<_BigBlock> _M_unpooled; const int _M_npools; }; diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector index 2c90765..e5e13ab 100644 --- a/libstdc++-v3/include/std/vector +++ b/libstdc++-v3/include/std/vector @@ -89,6 +89,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; } // namespace pmr +# ifdef _GLIBCXX_DEBUG + namespace _GLIBCXX_STD_C::pmr { + template<typename _Tp> + using vector + = _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>; + } // namespace _GLIBCXX_STD_C::pmr +# endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++17 |