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] Reduce size of class Symbol


>> I like the goal, but the problem is that you're always accessing the
>> plt_offset through the u_.from_object variant, no matter what variant
>> is actually there. While you've been careful to make sure that the
>> plt_offset field has the same offset in each variant, it's still both
>> fragile and technically illegal.
>
> This trick is allowed by the ISO C standard according to the
> following, and I'm assuming is also valid for C++.  Re accessing via
> the from_object variant, yes I guess it might be better style to
> create a new struct union member just containing plt_offset.
>
> From ISO/IEC 9899:1999 section 6.5.2.3 Structure and union members
>
> 5 One special guarantee is made in order to simplify the use of
>   unions: if a union contains several structures that share a common
>   initial sequence (see below), and if the union object currently
>   contains one of these structures, it is permitted to inspect the
>   common initial part of any of them anywhere that a declaration of
>   the completed type of the union is visible. Two structures share a
>   common initial sequence if corresponding members have compatible
>   types (and, for bit-fields, the same widths) for a sequence of one
>   or more initial members.

Still seems fragile to me -- you don't get any static checking that
the conditions are met. I prefer to split the union into two.

-cary


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