From cb26cf1a5b912ade1008a128833cf742835c4e43 Mon Sep 17 00:00:00 2001 From: Raoul Gough Date: Wed, 22 Oct 2003 23:28:37 +0000 Subject: [PATCH] Add std::swap overload for int_wrapper. This prevents a crash in container_proxy::swap_elements in test_deque_proxy.py with -O2 or higher on gcc 2.96 for i386-redhat-linux [SVN r20458] --- test/int_wrapper.hpp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/test/int_wrapper.hpp b/test/int_wrapper.hpp index 56998741..119e9e59 100755 --- a/test/int_wrapper.hpp +++ b/test/int_wrapper.hpp @@ -21,6 +21,7 @@ #include #include +#include #include struct int_wrapper { @@ -61,7 +62,7 @@ int_wrapper::int_wrapper () { if (our_trace_flag) { - printf ("int_wrapper %u ()\n", m_obj_number); + printf ("int_wrapper %u () at %p\n", m_obj_number, this); } } @@ -71,9 +72,10 @@ int_wrapper::int_wrapper (int i) { if (our_trace_flag) { - printf ("int_wrapper %u (%d)\n" + printf ("int_wrapper %u (%d) at %p\n" , m_obj_number - , m_int); + , m_int + , this); } } @@ -83,9 +85,11 @@ int_wrapper::int_wrapper (int_wrapper const &other) { if (our_trace_flag) { - printf ("int_wrapper %u (int_wrapper %u)\n" + printf ("int_wrapper %u (int_wrapper %u at %p) at %p\n" , m_obj_number - , other.m_obj_number); + , other.m_obj_number + , &other + , this); } } @@ -93,9 +97,11 @@ int_wrapper &int_wrapper::operator= (int_wrapper const &other) { if (our_trace_flag) { - printf ("int_wrapper %u = int_wrapper %u\n" + printf ("int_wrapper %u at %p = int_wrapper %u at %p\n" , m_obj_number - , other.m_obj_number); + , this + , other.m_obj_number + , &other); } m_int = other.m_int; @@ -107,7 +113,7 @@ int_wrapper::~int_wrapper () { if (our_trace_flag) { - printf ("~int_wrapper %u\n", m_obj_number); + printf ("~int_wrapper %u at %p\n", m_obj_number, this); } m_int = 0xbaaaaaad; @@ -168,4 +174,19 @@ int compare (int_wrapper const &lhs, int_wrapper const &rhs) } } +namespace std { + void swap (int_wrapper &first, int_wrapper &second) { + if (int_wrapper::our_trace_flag) + { + printf ("std::swap (int_wrapper %u at %p, int_wrapper %u at %p)\n" + , first.m_obj_number + , &first + , second.m_obj_number + , &second); + } + + swap (first.m_int, second.m_int); // Don't swap object numbers + } +} + #endif // int_wrapper_rmg_20030910_included