gold won't build with current gcc
Cary Coutant
ccoutant@gmail.com
Wed Dec 5 02:16:00 GMT 2018
> So we can fix this as follows. OK?
>
> * symtab.h (Symbol::Symbol): Avoid -Wclass-memaccess warning.
>
> diff --git a/gold/symtab.h b/gold/symtab.h
> index 089e156b45..16a244855d 100644
> --- a/gold/symtab.h
> +++ b/gold/symtab.h
> @@ -914,7 +914,7 @@ class Symbol
> // Instances of this class should always be created at a specific
> // size.
> Symbol()
> - { memset(this, 0, sizeof *this); }
> + { memset(static_cast<void*>(this), 0, sizeof *this); }
Sure, looks good to me.
I wonder if we can just get rid of the memset altogether -- it seems
to be there as a guard against carelessness and random garbage in
unused variant fields, as the various Symbol::init_xxx and
Sized_symbol::init_xxx methods ought to initialize everything
explicitly, and we just end up setting most fields to 0 twice.
Actually, it's probably more efficient to keep the memset and remove
all the explicit assignments that set fields to 0 or false. It's just
not very C++-ish.
-cary
More information about the Binutils
mailing list