aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2012-04-25 18:03:03 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2012-04-25 19:03:03 +0100
commit862023d77a81fc9000799ed3bbdcf86734d15ced (patch)
tree28099b063a68faa1527cf3db21bb956881137c82
parent98095aa3379c4db453d656b82f368e3bbacbfa07 (diff)
downloadgcc-862023d77a81fc9000799ed3bbdcf86734d15ced.zip
gcc-862023d77a81fc9000799ed3bbdcf86734d15ced.tar.gz
gcc-862023d77a81fc9000799ed3bbdcf86734d15ced.tar.bz2
scoped_allocator (scoped_allocator::__outermost): Do not pass non-POD to varargs function.
* include/std/scoped_allocator (scoped_allocator::__outermost): Do not pass non-POD to varargs function. * testsuite/20_util/scoped_allocator/1.cc: Fix test. From-SVN: r186836
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/std/scoped_allocator8
-rw-r--r--libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc18
3 files changed, 21 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 57d6ca8..678c7a4 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2012-04-25 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/std/scoped_allocator (scoped_allocator::__outermost): Do
+ not pass non-POD to varargs function.
+ * testsuite/20_util/scoped_allocator/1.cc: Fix test.
+
2012-04-24 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/52689
diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator
index edace98..fc2db7c 100644
--- a/libstdc++-v3/include/std/scoped_allocator
+++ b/libstdc++-v3/include/std/scoped_allocator
@@ -1,6 +1,6 @@
// <scoped_allocator> -*- C++ -*-
-// Copyright (C) 2011 Free Software Foundation, Inc.
+// Copyright (C) 2011, 2012 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
@@ -77,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc>
inline auto
- __do_outermost(_Alloc& __a, _Alloc&) -> decltype(__a.outer_allocator())
+ __do_outermost(_Alloc& __a, _Alloc*) -> decltype(__a.outer_allocator())
{ return __a.outer_allocator(); }
template<typename _Alloc>
@@ -87,8 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Alloc>
inline auto
- __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, __a))
- { return __do_outermost(__a, __a); }
+ __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, &__a))
+ { return __do_outermost(__a, &__a); }
template<typename _OuterAlloc, typename... _InnerAllocs>
class scoped_allocator_adaptor;
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc
index 823769f..21d1b05 100644
--- a/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc
@@ -1,6 +1,6 @@
// { dg-options "-std=gnu++0x" }
-// Copyright (C) 2011 Free Software Foundation, Inc.
+// Copyright (C) 2011, 2012 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
@@ -33,7 +33,7 @@ struct Element
Element(const allocator_type& a = allocator_type()) : alloc(a) { }
- Element(std::allocator_arg_t, const allocator_type& a, int i = 0)
+ Element(std::allocator_arg_t, const allocator_type& a, int = 0)
: alloc(a) { }
Element(std::allocator_arg_t, const allocator_type& a, const Element&)
@@ -53,6 +53,7 @@ void test01()
alloc1_type a1(1);
Element e;
EltVec ev1(1, e, a1);
+ VERIFY( ev1.get_allocator().get_personality() == 1 );
VERIFY( ev1[0].get_allocator().get_personality() == 1 );
}
@@ -60,14 +61,16 @@ void test02()
{
bool test __attribute((unused)) = false;
- typedef std::vector<Element, Element::allocator_type> EltVec;
+ typedef std::scoped_allocator_adaptor<Element::allocator_type> inner_alloc_type;
- typedef std::scoped_allocator_adaptor<EltVec::allocator_type,
- Element::allocator_type> alloc_type;
+ typedef std::vector<Element, inner_alloc_type> EltVec;
+
+ typedef std::scoped_allocator_adaptor<Element::allocator_type,
+ Element::allocator_type> alloc_type;
typedef std::vector<EltVec, alloc_type> EltVecVec;
- alloc_type a(1, 2);
+ alloc_type a(1, Element::allocator_type(2)); // outer=1, inner=2
Element e;
EltVec ev(1, e);
EltVecVec evv(1, ev, a);
@@ -76,7 +79,7 @@ void test02()
VERIFY( evv[0].get_allocator().get_personality() == 2 );
VERIFY( evv[0][0].get_allocator().get_personality() == 2 );
- alloc_type a2(3, 4);
+ alloc_type a2(3, Element::allocator_type(4)); // outer=3, inner=4
EltVecVec evv2(evv, a2); // copy with a different allocator
@@ -96,4 +99,5 @@ void test02()
int main()
{
test01();
+ test02();
}