This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gold incremental.cc gcc-9 compiler error


>>> Using gcc-9 git commit 4c9d340c8 (svn 261051) to compile current
>>> binutils master.
>>>
>>> /home/alan/src/binutils-gdb/gold/incremental.h:1704:9: error: implicitly-declared ‘constexpr gold::Incremental_binary::Input_reader::Input_reader(const gold::Incremental_binary::Input_reader&)’ is deprecated [-Werror=deprecated-copy]

I've committed the following patch.

Replacing push_back() with emplace_back() eliminates the calls to the
copy constructor, but I still had to provide explicit copy
constructors because of the call to vector::reserve(), which tries to
instantiate them even though they'll never actually be called when
reserve() is called on an empty vector.

-cary


2018-06-22  Cary Coutant  <ccoutant@gmail.com>

gold/
        * incremental.cc (Sized_incremental_binary::setup_readers): Use
        emplace_back for GCC 5 and later.
        * incremental.h (Incremental_binary::Input_reader): Provide copy
        constructor.
        (Sized_incremental_binary::Sized_input_reader): Likewise.

diff --git a/gold/incremental.cc b/gold/incremental.cc
index 21f060c945..7558d14ff5 100644
--- a/gold/incremental.cc
+++ b/gold/incremental.cc
@@ -311,7 +311,11 @@ Sized_incremental_binary<size, big_endian>::setup_readers()
   for (unsigned int i = 0; i < count; i++)
     {
       Input_entry_reader input_file = inputs.input_file(i);
+#if defined(__GNUC__) && __GNUC__ < 5
       this->input_entry_readers_.push_back(Sized_input_reader(input_file));
+#else
+      this->input_entry_readers_.emplace_back(input_file);
+#endif
       switch (input_file.type())
        {
        case INCREMENTAL_INPUT_OBJECT:
diff --git a/gold/incremental.h b/gold/incremental.h
index 1c3fbe1147..b4694b33d0 100644
--- a/gold/incremental.h
+++ b/gold/incremental.h
@@ -1368,6 +1368,9 @@ class Incremental_binary
     Input_reader()
     { }

+    Input_reader(const Input_reader&)
+    { }
+
     virtual
     ~Input_reader()
     { }
@@ -1708,6 +1711,10 @@ class Sized_incremental_binary : public
Incremental_binary
       : Input_reader(), reader_(r)
     { }

+    Sized_input_reader(const Sized_input_reader& r)
+      : Input_reader(), reader_(r.reader_)
+    { }
+
     virtual
     ~Sized_input_reader()
     { }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]