Advertisement
Guest User

BOOST_TEST, std::max and GCC in debug mode

a guest
Jan 6th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. // Break at binary_expr constructor
  2.  
  3. (gdb) br assertion.hpp:334
  4. Breakpoint 3 at 0x44e4c6: file boost/test/tools/assertion.hpp, line 334.
  5. (gdb) run
  6.  
  7. // Breakpoint hit
  8.  
  9. Breakpoint 3, boost::test_tools::assertion::binary_expr<boost::test_tools::assertion::value_expr<unsigned int>, unsigned int const&, boost::test_tools::assertion::op::EQ<unsigned int, unsigned int const, void> >::binary_expr(boost::test_to
  10. ols::assertion::value_expr<unsigned int>&&, unsigned int const&) (this=0x7fffffffc5a0, lhs=<unknown type in /var/tmp/double_ended/build/test/sandbox.test/gcc-4.8/debug/sandbox, CU 0x0, DIE 0xc6d0d>, rhs=@0x7fffffffc5f0: 3)
  11. at boost/test/tools/assertion.hpp:336
  12. 336 , m_rhs( std::forward<Rhs>(rhs) )
  13. (gdb) s
  14.  
  15. // Parent constructor omitted here for brevity
  16.  
  17. boost::test_tools::assertion::binary_expr<boost::test_tools::assertion::value_expr<unsigned int>, unsigned int const&, boost::test_tools::assertion::op::EQ<unsigned int, unsigned int const, void> >::binary_expr(boost::test_tools::assertion
  18. ::value_expr<unsigned int>&&, unsigned int const&) (this=0x7fffffffc5a0, lhs=<unknown type in /var/tmp/double_ended/build/test/sandbox.test/gcc-4.8/debug/sandbox, CU 0x0, DIE 0xc6d0d>, rhs=@0x7fffffffc5f0: 3)
  19. at boost/test/tools/assertion.hpp:337
  20. 337 {}
  21.  
  22. // binary_expr consturctor done, print it in the empty body
  23.  
  24. (gdb) print *this
  25. $22 = {<boost::test_tools::assertion::expression_base<boost::test_tools::assertion::binary_expr<boost::test_tools::assertion::value_expr<unsigned int>, unsigned int const&, boost::test_tools::assertion::op::EQ<unsigned int, unsigned int co
  26. nst, void> >, bool>> = {<No data fields>}, m_lhs = {<boost::test_tools::assertion::expression_base<boost::test_tools::assertion::value_expr<unsigned int>, unsigned int>> = {<No data fields>}, m_value = 3}, m_rhs = @0x7fffffffc5f0}
  27.  
  28. // Let's see if someone touches m_rhs, it's value is OK now
  29.  
  30. (gdb) watch *(unsigned*)0x7fffffffc5f0
  31. Hardware watchpoint 4: *(unsigned*)0x7fffffffc5f0
  32.  
  33. // Strange thing occures, the address of lazy_ostream matches the watched address. What's happening?
  34.  
  35. (gdb) c
  36. Continuing.
  37. Hardware watchpoint 4: *(unsigned*)0x7fffffffc5f0
  38.  
  39. Old value = 3
  40. New value = 7176336
  41. 0x000000000042caf1 in boost::unit_test::lazy_ostream::lazy_ostream (this=0x7fffffffc5f0, p_empty=false) at boost/test/utils/lazy_ostream.hpp:45
  42. 45 explicit lazy_ostream( bool p_empty = true ) : m_empty( p_empty ) {}
  43.  
  44. // Same memory is touched again
  45. // The new value is the final one, also printed by the failed test diagnostics
  46.  
  47. (gdb) c
  48. Continuing.
  49. Hardware watchpoint 4: *(unsigned*)0x7fffffffc5f0
  50.  
  51. Old value = 7176336
  52. New value = 7170128
  53. 0x000000000044e5db in boost::unit_test::lazy_ostream_impl<boost::unit_test::lazy_ostream, boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const> const&>::lazy_ostream_impl (this=0x7fffffffc5f0, prev=...,
  54. value=...) at boost/test/utils/lazy_ostream.hpp:60
  55. 60 , m_value( value )
  56.  
  57. // Message gets printed, the m_rhs was corrupted.
  58.  
  59. (gdb) c
  60. Continuing.
  61. sandbox.cpp(8): error: in "sandbox": check 3u == ((std::max)(0u, 3u)) has failed [3 != 7170128]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement