• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2011 John Maddock
2 *
3 * Use, modification and distribution is subject to the
4 * Boost Software License, Version 1.0. (See accompanying
5 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6 */
7 
8 // Test of bug #5526 (https://svn.boost.org/trac/boost/ticket/5526)
9 
10 #include <boost/smart_ptr/scoped_ptr.hpp>
11 #include <boost/pool/pool.hpp>
12 #include <boost/pool/singleton_pool.hpp>
13 #include <boost/assert.hpp>
14 
15 struct bad
16 {
badbad17    bad()
18    {
19       buf = static_cast<int*>(boost::singleton_pool<int, sizeof(int)>::malloc());
20       *buf = 0x1234;
21    }
~badbad22    ~bad()
23    {
24       BOOST_ASSERT(*buf == 0x1234);
25       boost::singleton_pool<int, sizeof(int)>::free(buf);
26    }
27    int* buf;
28 };
29 
30 boost::scoped_ptr<bad> aptr;
31 
main()32 int main()
33 {
34    aptr.reset(new bad());
35    return 0;
36 }
37