gold incremental.cc gcc-9 compiler error

Cary Coutant ccoutant@gmail.com
Thu Jun 7 02:14:00 GMT 2018


>> 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]
>
> Perhaps this?
>
> Avoid copy constructor in Sized_incremental_binary::setup_readers
>
>         * incremental.h (Sized_incremental_binary::input_entry_readers_):
>         Make it a vector of pointers.
>         (Sized_incremental_binary::do_get_input_reader): Adjust to suit.
>         * incremental.cc (Sized_incremental_binary::setup_readers):
>         Likewise.
>
> diff --git a/gold/incremental.cc b/gold/incremental.cc
> index 21f060c945..25061422da 100644
> --- a/gold/incremental.cc
> +++ b/gold/incremental.cc
> @@ -311,7 +311,8 @@ 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);
> -      this->input_entry_readers_.push_back(Sized_input_reader(input_file));
> +      Sized_input_reader* sir = new Sized_input_reader(input_file);
> +      this->input_entry_readers_.push_back(sir);

What I really ought to be using here is emplace_back() to construct
the new reader in place, and avoid the copy:

+      this->input_entry_readers_.emplace_back(input_file);

But I need to figure out what damage that will do to the ability to
build gold with older versions of GCC (e.g., back to 4.1.3), or
whether it's still important to support versions that far back.

I suppose I could use a conditional on the GCC version, to use
push_back() for older versions, and emplace_back() for new-enough
versions, assuming that the older versions won't complain about the
deprecated default copy constructor (which, I'm fairly certain isn't a
correctness issue).

-cary



More information about the Binutils mailing list