]> code.ossystems Code Review - openembedded-core.git/blob
d3d2cea6cc90142c7a37a41f310713548d21f982
[openembedded-core.git] /
1 Upstream-Status: Inappropriate [Backport]
2 From f6e12aec843ba3a839f49b60a5ca092f2fadd876 Mon Sep 17 00:00:00 2001
3 From: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Sun, 10 Apr 2011 16:29:05 +0000
5 Subject: [PATCH 098/200] 2011-04-10  Jonathan Wakely  <jwakely.gcc@gmail.com>
6
7         PR libstdc++/48541
8         * include/std/functional (_Base_manager::_M_get_pointer): Use
9         addressof.
10         * testsuite/20_util/function/48541.cc: New.
11
12
13
14 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172242 138bc75d-0d04-0410-961f-82ee72b054a4
15
16 index 6643b76..660e371 100644
17 --- a/libstdc++-v3/include/std/functional
18 +++ b/libstdc++-v3/include/std/functional
19 @@ -1586,7 +1586,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
20         _M_get_pointer(const _Any_data& __source)
21         {
22           const _Functor* __ptr =
23 -           __stored_locally? &__source._M_access<_Functor>()
24 +           __stored_locally? std::__addressof(__source._M_access<_Functor>())
25             /* have stored a pointer */ : __source._M_access<_Functor*>();
26           return const_cast<_Functor*>(__ptr);
27         }
28 diff --git a/libstdc++-v3/testsuite/20_util/function/48451.cc b/libstdc++-v3/testsuite/20_util/function/48451.cc
29 new file mode 100644
30 index 0000000..f812367
31 --- /dev/null
32 +++ b/libstdc++-v3/testsuite/20_util/function/48451.cc
33 @@ -0,0 +1,40 @@
34 +// { dg-options "-std=gnu++0x" }
35 +// { dg-do compile }
36 +// Copyright (C) 2011 Free Software Foundation, Inc.
37 +//
38 +// This file is part of the GNU ISO C++ Library.  This library is free
39 +// software; you can redistribute it and/or modify it under the
40 +// terms of the GNU General Public License as published by the
41 +// Free Software Foundation; either version 3, or (at your option)
42 +// any later version.
43 +//
44 +// This library is distributed in the hope that it will be useful,
45 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
46 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47 +// GNU General Public License for more details.
48 +//
49 +// You should have received a copy of the GNU General Public License along
50 +// with this library; see the file COPYING3.  If not see
51 +// <http://www.gnu.org/licenses/>.
52 +
53 +// libstdc++/48451
54 +
55 +#include <functional>
56 +
57 +struct X {
58 +  void operator () () const { }
59 +  float operator & () const { return 1.2345; }
60 +};
61 +
62 +void test01()
63 +{
64 +  X x;
65 +  std::function<void()> f(x);
66 +  f();
67 +}
68 +
69 +int main()
70 +{
71 +  test01();
72 +  return 0;
73 +}
74 -- 
75 1.7.0.4
76