test_valgrind_fail_2.cpp 498 B

1234567891011121314151617181920
  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 #2656 (https://svn.boost.org/trac/boost/ticket/2656)
  8. #include <boost/pool/pool.hpp>
  9. int main()
  10. {
  11. boost::pool<> p(sizeof(int));
  12. int* ptr = static_cast<int*>((p.malloc)());
  13. *ptr = 0;
  14. (p.free)(ptr);
  15. *ptr = 2; // write to freed memory
  16. return 0;
  17. }