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 won't build with current gcc


> 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


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