From: redi Date: Wed, 25 Apr 2012 21:53:20 +0000 (+0000) Subject: * include/std/scoped_allocator (scoped_allocator::__outermost): Do X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=489538d420d01ba667966917315530a0bcf88aad * include/std/scoped_allocator (scoped_allocator::__outermost): Do not pass non-POD to varargs function. * testsuite/20_util/scoped_allocator/1.cc: Fix test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186841 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1dcae123ccd..0240320620b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2012-04-25 Jonathan Wakely + + * 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-23 Chris Jefferson PR testsuite/53046 diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator index edace9840d1..fc2db7cbd66 100644 --- a/libstdc++-v3/include/std/scoped_allocator +++ b/libstdc++-v3/include/std/scoped_allocator @@ -1,6 +1,6 @@ // -*- 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 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 @@ -87,8 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template 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 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 823769fb563..21d1b055512 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 EltVec; + typedef std::scoped_allocator_adaptor inner_alloc_type; - typedef std::scoped_allocator_adaptor alloc_type; + typedef std::vector EltVec; + + typedef std::scoped_allocator_adaptor alloc_type; typedef std::vector 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(); }