test_bug_5526.cpp 782 B

123456789101112131415161718192021222324252627282930313233343536
  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. // Test of bug #5526 (https://svn.boost.org/trac/boost/ticket/5526)
  8. #include <boost/smart_ptr/scoped_ptr.hpp>
  9. #include <boost/pool/pool.hpp>
  10. #include <boost/pool/singleton_pool.hpp>
  11. #include <boost/assert.hpp>
  12. struct bad
  13. {
  14. bad()
  15. {
  16. buf = static_cast<int*>(boost::singleton_pool<int, sizeof(int)>::malloc());
  17. *buf = 0x1234;
  18. }
  19. ~bad()
  20. {
  21. BOOST_ASSERT(*buf == 0x1234);
  22. boost::singleton_pool<int, sizeof(int)>::free(buf);
  23. }
  24. int* buf;
  25. };
  26. boost::scoped_ptr<bad> aptr;
  27. int main()
  28. {
  29. aptr.reset(new bad());
  30. return 0;
  31. }