]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 May 2010 18:39:46 +0000 (18:39 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 May 2010 18:39:46 +0000 (18:39 +0000)
PR libstdc++/42832
* include/std/functional (function<>::swap): Perform bytewise
swap of _M_functor.
* include/tr1/functional (function<>::swap): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159940 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/functional
libstdc++-v3/include/tr1/functional

index 0af8ae6c73034a5c7f25921653f97beac48ccbf5..b6a0b1e970790c8b9da4c18e928851546af20c10 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-27  Jason Merrill  <jason@redhat.com>
+
+       Revert:
+       PR libstdc++/42832
+       * include/std/functional (function<>::swap): Perform bytewise
+       swap of _M_functor.
+       * include/tr1/functional (function<>::swap): Likewise.
+
 2010-05-27  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR libstdc++/40497
index 7f6d8b6c4f663d660ae4af6024a644bf414380c1..b6cc6d5e0720134b97b83bbb2e2c1b828cfb9c67 100644 (file)
@@ -1948,16 +1948,9 @@ namespace std
        */
       void swap(function& __x)
       {
-       /* We cannot perform direct assignments of the _M_functor
-          parts as they are of type _Any_data and have a different
-          dynamic type.  Doing so would violate type-based aliasing
-          rules and lead to spurious miscompilations.
-          Instead perform a bytewise exchange of the memory of
-          both POD objects.
-          ???  A wordwise exchange honoring alignment of _M_functor
-          would be more efficient.  See PR42845.  */
-       for (unsigned i = 0; i < sizeof (_M_functor._M_pod_data); ++i)
-         std::swap (_M_functor._M_pod_data[i], __x._M_functor._M_pod_data[i]);
+       _Any_data __old_functor = _M_functor;
+       _M_functor = __x._M_functor;
+       __x._M_functor = __old_functor;
        _Manager_type __old_manager = _M_manager;
        _M_manager = __x._M_manager;
        __x._M_manager = __old_manager;
index ae080bb5df99f627e04451c3ecfd79e43bc87a41..3340de6fffc252c015ebbb135f4f4ca00b16c769 100644 (file)
@@ -1907,16 +1907,9 @@ namespace tr1
        */
       void swap(function& __x)
       {
-        /* We cannot perform direct assignments of the _M_functor
-          parts as they are of type _Any_data and have a different
-          dynamic type.  Doing so would violate type-based aliasing
-          rules and lead to spurious miscompilations.
-          Instead perform a bytewise exchange of the memory of
-          both POD objects.
-          ???  A wordwise exchange honoring alignment of _M_functor
-          would be more efficient.  See PR42845.  */
-       for (unsigned i = 0; i < sizeof (_M_functor._M_pod_data); ++i)
-         std::swap (_M_functor._M_pod_data[i], __x._M_functor._M_pod_data[i]);
+       _Any_data __old_functor = _M_functor;
+       _M_functor = __x._M_functor;
+       __x._M_functor = __old_functor;
        _Manager_type __old_manager = _M_manager;
        _M_manager = __x._M_manager;
        __x._M_manager = __old_manager;