]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Use local, not temporary, when using swap ().
authorMark Wielaard <mjw@redhat.com>
Wed, 24 Nov 2010 10:55:35 +0000 (11:55 +0100)
committerMark Wielaard <mjw@redhat.com>
Thu, 25 Nov 2010 13:10:09 +0000 (14:10 +0100)
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.

libdw/c++/dwarf_edit
libdw/c++/dwarf_output

index 705a5ee300abf02417d52b512957638a52515fb6..19e5493f12a82ffe71fc157014f3869788170ce9 100644 (file)
@@ -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 (...)
          {
index 9e5c1f632d2dc7aa50727b93f605cdf90d706033..e88da5c79116aab839785240c785b1d20ce971e4 100644 (file)
@@ -561,7 +561,8 @@ namespace elfutils
     inline dwarf_output (const input &dw, dwarf_output_collector &c)
     {
       copier<input> 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<typename file>