From: Mark Wielaard Date: Wed, 24 Nov 2010 10:55:35 +0000 (+0100) Subject: Use local, not temporary, when using swap (). X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d383d314a6b4a29e8279f327e61ff4e678e4599d;p=thirdparty%2Felfutils.git Use local, not temporary, when using swap (). g++ 4.5 now detects that swap wants a reference as argument. You cannot use a temporary, which is an lvalue and so cannot be used as reference. The lifetime of the temporary cannot be guaranteed, and so because it isn't const, g++ refuses to use it as reference. --- diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 705a5ee30..19e5493f1 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -1,5 +1,5 @@ /* elfutils::dwarf_edit -- mutable DWARF representation in -*- C++ -*- - Copyright (C) 2009 Red Hat, Inc. + Copyright (C) 2009, 2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -169,8 +169,10 @@ namespace elfutils try { _m_tag = die.tag (); - _m_attributes.swap (attributes_type (die.attributes (), arg)); - _m_children.swap (children_type (die.children (), arg)); + attributes_type t_attrs = attributes_type (die.attributes (), arg); + _m_attributes.swap (t_attrs); + children_type t_children = children_type (die.children (), arg); + _m_children.swap (t_children); } catch (...) { diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 9e5c1f632..e88da5c79 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -561,7 +561,8 @@ namespace elfutils inline dwarf_output (const input &dw, dwarf_output_collector &c) { copier maker (c); - _m_units.swap (compile_units_type (dw.compile_units (), maker)); + compile_units_type tmp_units (dw.compile_units (), maker); + _m_units.swap (tmp_units); } template