This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gold won't build with current gcc
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 4 Dec 2018 18:16:03 -0800
- Subject: Re: gold won't build with current gcc
- References: <20181205014630.GC29034@bubble.grove.modra.org>
> 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