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
+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
*/
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;
*/
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;