BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001113 [uClibc++] Other major always 12-13-06 01:57 12-14-06 17:29
Reporter peter_schueller View Status public  
Assigned To gkajmowi
Priority normal Resolution fixed  
Status resolved   Product Version 0.2.0
Summary 0001113: deque::swap implemented incorrectly (contains patch)
Description the swap method of deque is implemented as abort()

the swap(deque, deque) method is correctly implemented

i moved the implementation from swap(deque, deque) into deque::swap() and simply call deque1.swap(deque2) in swap(deque, deque).
Additional Information patch:

Index: include/deque
===================================================================
--- include/deque (revision 1813)
+++ include/deque (revision 1814)
@@ -35,7 +35,7 @@
        template <class T, class Allocator> bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
        template <class T, class Allocator> bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
        template <class T, class Allocator> bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
- template <class T, class Allocator> void swap(deque<T,Allocator>& x, deque<T,Allocator>& y);
+ template <class _T, class _Allocator> void swap(deque<_T,_Allocator>& x, deque<_T,_Allocator>& y);

        template <class T, class Allocator> class _UCXXEXPORT deque {
        public:
@@ -710,9 +710,36 @@
                return deque_iter(this, first.element);
        }

- template<class T, class Allocator> void deque<T, Allocator>::swap(deque<T,Allocator>&)
+ template<class T, class Allocator> void deque<T,
+ Allocator>::swap(deque<T,Allocator>& other)
        {
- abort();
+ T * temp_data;
+ typename deque<T,Allocator>::size_type temp_size;
+
+ //Swap data pointers
+ temp_data = data;
+ data = other.data;
+ other.data = temp_data;
+
+ //Swap array sizes
+ temp_size = data_size;
+ data_size = other.data_size;
+ other.data_size = temp_size;
+
+ //Swap num array elements
+ temp_size = elements;
+ elements = other.elements;
+ other.elements = temp_size;
+
+ //Swap first_pointer
+ temp_size = first_element;
+ first_element = other.first_element;
+ other.first_element = temp_size;
+
+ //Swap last_pointer
+ temp_size = last_element;
+ last_element = other.last_element;
+ other.last_element = temp_size;
        }
 
        template<class T, class Allocator> void deque<T, Allocator>::clear()
@@ -779,39 +806,7 @@
        template <class T, class Allocator> bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
        template <class T, class Allocator> bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
        template <class T, class Allocator> _UCXXEXPORT void swap(deque<T,Allocator>& x, deque<T,Allocator>& y){
- T * temp_data;
-// T temp_value;
- typename deque<T,Allocator>::size_type temp_size;
-
- //Swap data pointers
- temp_data = x.data;
- x.data = y.data;
- y.data = temp_data;
-
- //Swap temp values;
-// temp_value = x.defaultValue;
-// x.defaultValue = y.defaultValue;
-// y.defaultValue = temp_value;
-
- //Swap array sizes
- temp_size = x.data_size;
- x.data_size = y.data_size;
- y.data_size = temp_size;
-
- //Swap num array elements
- temp_size = x.elements;
- x.elements = y.elements;
- y.elements = temp_size;
-
- //Swap first_pointer
- temp_size = x.first_element;
- x.first_element = y.first_element;
- y.first_element = temp_size;
-
- //Swap last_pointer
- temp_size = x.last_element;
- x.last_element = y.last_element;
- y.last_element = temp_size;
+ x.swap(y);
        }
 
Attached Files

- Relationships

- Notes
(0001863)
gkajmowi
12-14-06 17:29

Fixed in SVN
I took the existing code to get the same result.
 

- Issue History
Date Modified Username Field Change
12-13-06 01:57 peter_schueller New Issue
12-13-06 01:57 peter_schueller Status new => assigned
12-13-06 01:57 peter_schueller Assigned To  => gkajmowi
12-14-06 17:29 gkajmowi Status assigned => resolved
12-14-06 17:29 gkajmowi Fixed in Version  => 0.2.2
12-14-06 17:29 gkajmowi Resolution open => fixed
12-14-06 17:29 gkajmowi Note Added: 0001863


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker